From 90b81cf4c487b1880518cd1136e5e7530cb59aca Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Thu, 12 Apr 2018 16:06:53 -0400 Subject: [PATCH] move check stack to cmake and run in Jenkins --- Jenkinsfile | 15 +++++++++++++++ Makefile | 12 +----------- platforms/nuttx/CMakeLists.txt | 22 ++++++++++++++++++++-- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6be49431ff..dd8c943600 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -219,6 +219,21 @@ pipeline { } } + stage('check stack') { + agent { + docker { + image 'px4io/px4-dev-nuttx:2018-03-30' + args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw' + } + } + steps { + sh 'export' + sh 'make distclean' + sh 'make px4fmu-v2_default stack_check' + sh 'make distclean' + } + } + stage('ROS vtol mission new 1') { agent { docker { diff --git a/Makefile b/Makefile index 741c17deb9..758d7b6824 100644 --- a/Makefile +++ b/Makefile @@ -308,7 +308,7 @@ tests_offboard: rostest # static analyzers (scan-build, clang-tidy, cppcheck) # -------------------------------------------------------------------- -.PHONY: scan-build posix_sitl_default-clang clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck check_stack +.PHONY: scan-build posix_sitl_default-clang clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck scan-build: @export CCC_CC=clang @@ -343,16 +343,6 @@ cppcheck: posix_sitl_default @cppcheck -i$(SRC_DIR)/src/examples --enable=performance --std=c++11 --std=c99 --std=posix --project=$(SRC_DIR)/build/posix_sitl_default/compile_commands.json --xml-version=2 2> $(SRC_DIR)/build/cppcheck/cppcheck-result.xml > /dev/null @cppcheck-htmlreport --source-encoding=ascii --file=$(SRC_DIR)/build/cppcheck/cppcheck-result.xml --report-dir=$(SRC_DIR)/build/cppcheck --source-dir=$(SRC_DIR)/src/ -check_stack: px4fmu-v4pro_default - @echo "Checking worst case stack usage with checkstack.pl ..." - @echo " " - @echo "Top 10:" - @cd $(SRC_DIR)/build/px4fmu-v4pro_default && mkdir -p stack_usage && arm-none-eabi-objdump -d nuttx_px4fmu-v4pro_default.elf | $(SRC_DIR)/Tools/stack_usage/checkstack.pl arm 0 > stack_usage/checkstack_output.txt 2> stack_usage/checkstack_errors.txt - @head -n 10 $(SRC_DIR)/build/px4fmu-v4pro_default/stack_usage/checkstack_output.txt | c++filt - @echo " " - @echo "Symbols with 'main', 'thread' or 'task':" - @cat $(SRC_DIR)/build/px4fmu-v4pro_default/stack_usage/checkstack_output.txt | c++filt | grep -E 'thread|main|task' - # Cleanup # -------------------------------------------------------------------- .PHONY: clean submodulesclean submodulesupdate gazeboclean distclean diff --git a/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/CMakeLists.txt index e3b5138d43..708a528de0 100644 --- a/platforms/nuttx/CMakeLists.txt +++ b/platforms/nuttx/CMakeLists.txt @@ -171,13 +171,31 @@ add_custom_target(size COMMAND size ${FW_NAME} DEPENDS ${FW_NAME} WORKING_DIRECTORY ${PX4_BINARY_DIR} + USES_TERMINAL ) # print weak symbols -add_custom_target(check_weak - COMMAND ${NM} ${FW_NAME} | ${GREP} " w " | cat +add_custom_target(weak_symbols + COMMAND ${CMAKE_NM} $ | ${GREP} " w " | cat DEPENDS ${FW_NAME} VERBATIM + USES_TERMINAL + ) + +add_custom_target(stack_check + COMMAND ${CMAKE_COMMAND} -E make_directory stack_usage && ${CMAKE_OBJDUMP} -d $ | ${PX4_SOURCE_DIR}/Tools/stack_usage/checkstack.pl arm 0 > stack_usage/checkstack_output.txt 2> stack_usage/checkstack_errors.txt + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMAND ${CMAKE_COMMAND} -E echo "Top 50:" + COMMAND ${CMAKE_COMMAND} -E echo "--------------------------------------------------------------------------------" + COMMAND head -n 50 stack_usage/checkstack_output.txt | c++filt + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMAND ${CMAKE_COMMAND} -E echo "Symbols with 'run', 'task', 'thread', 'main', 'update':" + COMMAND ${CMAKE_COMMAND} -E echo "--------------------------------------------------------------------------------" + COMMAND cat stack_usage/checkstack_output.txt | c++filt | grep -E 'run|task|thread|main|update' + DEPENDS ${FW_NAME} + WORKING_DIRECTORY ${PX4_BINARY_DIR} + VERBATIM ) # debugger helpers