esp32 idf vscode debug错误
vscode中配置文件采用的是正点原子的,调用gdb的时候,提示报错,找不到相应的命令
launch.json文件中gdb的配置如下
{"version": "0.2.0","configurations": [ { "name": "GDB", "type": "cppdbg", "request": "launch", "MIMode": "gdb", "miDebuggerPath": "${command:espIdf.getXtensaGdb}", "program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf", "windows": { "program": "${workspaceFolder}\\build\\${command:espIdf.getProjectName}.elf" }, "cwd": "${workspaceFolder}", "environment": [{ "name": "PATH", "value": "${config:idf.customExtraPaths}" }], "setupCommands": [ { "text": "target remote :3333" }, { "text": "set remote hardware-watchpoint-limit 2"}, { "text": "mon reset halt" }, { "text": "thb app_main" }, { "text": "flushregs" } ], "externalConsole": false, "logging": { "engineLogging": true } } ]
}
主要问题出现在这句配置"miDebuggerPath": "${command:espIdf.getXtensaGdb}", 错误提示如下
原因应该是路径不对或者命令不对
手动配置绝对路径也不无法正常debug
查看esp-idf 文档中
发现官方是这样配置如下
{"configurations": [{"type": "gdbtarget","request": "attach","name": "Eclipse CDT Remote","program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf","initCommands": ["set remote hardware-watchpoint-limit {IDF_TARGET_CPU_WATCHPOINT_NUM}","mon reset halt","maintenance flush register-cache"],"gdb": "${command:espIdf.getToolchainGdb}","target": {"connectCommands": ["set remotetimeout 20","-target-select extended-remote localhost:3333"]}}]
}
gdb配置如下,就可以正常debug了
"gdb": "${command:espIdf.getToolchainGdb}",
完整配置launch.json
{"version": "0.2.0","configurations": [ { "name": "GDB", "type": "cppdbg", "request": "launch", "MIMode": "gdb", "miDebuggerPath": "${command:espIdf.getToolchainGdb}","program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf", "windows": { "program": "${workspaceFolder}\\build\\${command:espIdf.getProjectName}.elf" }, "cwd": "${workspaceFolder}", "environment": [{ "name": "PATH", "value": "${config:idf.customExtraPaths}" }], "setupCommands": [ { "text": "target remote :3333" }, { "text": "set remote hardware-watchpoint-limit 2"}, { "text": "mon reset halt" }, { "text": "thb app_main" }, { "text": "flushregs" } ], "externalConsole": false, "logging": { "engineLogging": true } } ]
}