Im使用带有cortex debug/jlink扩展的vscode来调试我的cortex m目标。
我需要在启动期间发出GDB命令的能力(连接到调试和启动会话(。
在这种特定情况下,我想发出命令";目录C:。。。\BUILD";到GDB以替换输出文件(*.elf(.中的绝对路径
然而,我不知道如何在VSCode launch.json文件中发出GDB命令。
示例:
{
// extension: cortex debug
"version": "0.2.0",
"configurations": [
{
"type": "cortex-debug",
"request": "launch",
"name": "Debug J-Link",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}/BUILD/output.elf",
"serverpath": "/usr/bin/JLinkGDBServerExe",
"servertype": "jlink",
"device": "...",
"interface": "swd",
"serialNumber": "",
"jlinkscript": "",
"runToMain": true,
"svdFile": ""
},
...
如何向其中添加GDB命令?
下面是我对ARM Cortex-M4板的启动配置。我只是使用cppdbg
类型。但请注意mi*
属性:
{
"name": "reel_board",
"type": "cppdbg",
"request": "launch",
"program": "your.elf",
"args": ["-ex", "load"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/your/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"miDebuggerServerAddress": "localhost:<your gdbserver port>",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
启动gdbserver后,在VSC中按F5键启动gdb客户端。
您可以使用"postStartSessionCommands">和";postAttachCommands">参数。可以放置在launch.json中的所有受支持参数的完整列表可在Cortex debug github上找到:https://github.com/Marus/cortex-debug/blob/master/package.json.请记住,这些接受字符串数组,因此一个例子是:
{
"cwd": "${workspaceRoot}",
"executable": "./build/zephyr/zephyr.signed.confirmed.hex",
"postStartSessionCommands": [
"file /x/y/z/zephyr.elf"
],
"breakAfterReset": true,
(...)
}