cmake generate vscode launch.json

This commit is contained in:
Daniel Agar
2019-09-21 13:06:49 -04:00
parent 42ca17ce77
commit 86dc4c5a00
8 changed files with 433 additions and 282 deletions
+53
View File
@@ -166,6 +166,59 @@ add_custom_target(weak_symbols
# debugger helpers
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/gdbinit.in ${PX4_BINARY_DIR}/.gdbinit)
# vscode launch.json
# FIXME: hack to skip if px4_io-v2 because it's a build within a build
if(NOT PX4_BUILD MATCHES "px4_io-v2")
if(CONFIG_ARCH_CHIP_MK66FN2M0VMD18)
set(DEBUG_DEVICE "MK66FN2M0xxx18")
set(DEBUG_SVD_FILE "MK66F18.svd")
elseif(CONFIG_ARCH_CHIP_STM32F100C8)
set(DEBUG_DEVICE "STM32F100C8")
set(DEBUG_SVD_FILE "STM32F100xx.svd")
elseif(CONFIG_ARCH_CHIP_STM32F103RB)
set(DEBUG_DEVICE "STM32F103C4")
set(DEBUG_SVD_FILE "STM32F103xx.svd")
elseif(CONFIG_ARCH_CHIP_STM32F302K8)
set(DEBUG_DEVICE "STM32F302K8")
set(DEBUG_SVD_FILE "STM32F302.svd")
elseif(CONFIG_ARCH_CHIP_STM32F303CC)
set(DEBUG_DEVICE "STM32F303CC")
set(DEBUG_SVD_FILE "STM32F303.svd")
elseif(CONFIG_ARCH_CHIP_STM32F405RG)
set(DEBUG_DEVICE "STM32F405RG")
set(DEBUG_SVD_FILE "STM32F405.svd")
elseif(CONFIG_ARCH_CHIP_STM32F427V)
set(DEBUG_DEVICE "STM32F427VI")
set(DEBUG_SVD_FILE "STM32F427.svd")
elseif(CONFIG_ARCH_CHIP_STM32F429V)
set(DEBUG_DEVICE "STM32F429VI")
set(DEBUG_SVD_FILE "STM32F429.svd")
elseif(CONFIG_ARCH_CHIP_STM32F446R)
set(DEBUG_DEVICE "STM32F446RC")
set(DEBUG_SVD_FILE "STM32F446.svd")
elseif(CONFIG_ARCH_CHIP_STM32F469I)
set(DEBUG_DEVICE "STM32F469IE")
set(DEBUG_SVD_FILE "STM32F469.svd")
elseif(CONFIG_ARCH_CHIP_STM32F745VG)
set(DEBUG_DEVICE "STM32F745VG")
set(DEBUG_SVD_FILE "STM32F7x5.svd")
elseif(CONFIG_ARCH_CHIP_STM32F765II)
set(DEBUG_DEVICE "STM32F765II")
set(DEBUG_SVD_FILE "STM32F7x5.svd")
elseif(CONFIG_ARCH_CHIP_STM32F777NI)
set(DEBUG_DEVICE "STM32F777NI")
set(DEBUG_SVD_FILE "STM32F7x7.svd")
endif()
file(GLOB_RECURSE DEBUG_SVD_FILE_PATH ${CMAKE_SOURCE_DIR}/../cmsis-svd/*/${DEBUG_SVD_FILE})
if(DEBUG_SVD_FILE-NOTFOUND)
set(DEBUG_SVD_FILE "")
else()
message(STATUS "Found SVD: ${DEBUG_SVD_FILE_PATH}")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/launch.json.in ${PX4_SOURCE_DIR}/.vscode/launch.json @ONLY)
endif()
add_custom_target(debug
COMMAND ${GDB} -iex 'set auto-load safe-path ${PX4_BINARY_DIR}' $<TARGET_FILE:px4>
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
+44
View File
@@ -0,0 +1,44 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "jlink (@PX4_BOARD@)",
"device": "@DEBUG_DEVICE@",
"svdFile": "@DEBUG_SVD_FILE_PATH@",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "jlink",
"interface": "swd",
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchCommands": [
"source ${workspaceRoot}/platforms/nuttx/Debug/PX4",
"source ${workspaceRoot}/platforms/nuttx/Debug/NuttX",
"source ${workspaceRoot}/platforms/nuttx/Debug/ARMv7M",
"set mem inaccessible-by-default off",
"set print pretty",
]
},
{
"name": "blackmagic (@PX4_BOARD@)",
"device": "@DEBUG_DEVICE@",
"svdFile": "@DEBUG_SVD_FILE_PATH@",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "bmp",
"BMPGDBSerialPort": "/dev/ttyACM0",
"interface": "swd",
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchCommands": [
"source ${workspaceRoot}/platforms/nuttx/Debug/PX4",
"source ${workspaceRoot}/platforms/nuttx/Debug/NuttX",
"source ${workspaceRoot}/platforms/nuttx/Debug/ARMv7M",
"set mem inaccessible-by-default off",
"set print pretty",
]
}
]
}
+246
View File
@@ -0,0 +1,246 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "SITL (gazebo iris)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s",
"etc/init.d-posix/rcS",
"-t",
"${workspaceFolder}/test_data"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/px4_sitl_default/tmp",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "iris"
}
],
"externalConsole": false,
"preLaunchTask": "gazebo iris",
"postDebugTask": "gazebo kill",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
},
{
"name": "SITL (gazebo plane)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s",
"etc/init.d-posix/rcS",
"-t",
"${workspaceFolder}/test_data"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/px4_sitl_default/tmp",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "plane"
}
],
"externalConsole": false,
"preLaunchTask": "gazebo plane",
"postDebugTask": "gazebo kill",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
},
{
"name": "SITL (gazebo standard_vtol)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s",
"etc/init.d-posix/rcS",
"-t",
"${workspaceFolder}/test_data"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/px4_sitl_default/tmp",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "standard_vtol"
}
],
"externalConsole": false,
"preLaunchTask": "gazebo standard_vtol",
"postDebugTask": "gazebo kill",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
},
{
"name": "SITL (jmavsim iris)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s",
"etc/init.d-posix/rcS",
"-t",
"${workspaceFolder}/test_data"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/px4_sitl_default/tmp",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "iris"
}
],
"preLaunchTask": "jmavsim",
"postDebugTask": "jmavsim kill",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
},
{
"name": "SITL (shell)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s",
"etc/init.d-posix/rcS",
"-t",
"${workspaceFolder}/test_data"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/px4_sitl_default/tmp",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "shell"
}
],
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
},
]
}
+3
View File
@@ -104,3 +104,6 @@ add_custom_target(list_vmd_make_targets
COMMENT "List of acceptable '${PX4_BOARD}' <viewer_model_debugger> targets:"
VERBATIM
)
# vscode launch.json
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/launch.json.in ${PX4_SOURCE_DIR}/.vscode/launch.json COPYONLY)