move check stack to cmake and run in Jenkins

This commit is contained in:
Daniel Agar 2018-04-12 16:06:53 -04:00
parent 0c9f483581
commit 90b81cf4c4
3 changed files with 36 additions and 13 deletions

15
Jenkinsfile vendored
View File

@ -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 {

View File

@ -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

View File

@ -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} $<TARGET_FILE:${FW_NAME}> | ${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 $<TARGET_FILE:${FW_NAME}> | ${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