Visual Studio 2019 调试嵌入式目标。如何强制 VS 不将其视为 windows 可执行文件
Visual Studio 2019 debug embedded targets. How to force VS to not treat it as a windows executable
我正在尝试在 VS 2019 中设置 Cmake ARM uC (STM32) 嵌入式项目。
项目构建正常,但我很难启动调试会话。
我已修改launch.vs.json
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "cppdbg",
"name": "GCEC-FW.elf",
"project": "out\build\IoT-Debug\GCEC-FW.elf",
"projectTarget": "",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}\BUILD\${workspaceRootFolderName}.elf",
"MIMode": "gdb",
"externalConsole": true,
"inheritEnvironments": [
"gcc_arm"
],
"miDebuggerPath": "${env.gccpath}\bin\arm-none-eabi-gdb.exe",
"setupCommands": [
{
"text": "-environment-cd ${workspaceRoot}/BUILD"
},
{
"text": "-file-exec-and-symbols ${workspaceRootFolderName}.elf",
"description": "load file",
"ignoreFailures": false
},
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"visualizerFile": "${debugInfo.linuxNatvisPath}",
"showDisplayString": true,
"miDebuggerServerAddress": "localhost:3333",
"launchCompleteCommand": "None",
"debugServerPath": "C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.3.0\Servers\J-Link_gdbserver\JLinkGDBServerCL.exe",
"debugServerArgs": "-port 2331 -s -CPU Cortex-M -device STM32F427II -endian little -speed 4000 -vd -swoport 2332",
"serverStarted": "GDB\ server\ started",
"filterStderr": true,
"filterStdout": true
}
]
}
但是当我尝试启动调试会话时,我收到错误消息,指出我的 .elf
文件不是 win32 可执行文件(实际上是正确的 - 它不是)。
问题是:VS 必须做什么才能开始这个会话?
编辑
我需要在添加附加新的微控制器调试配置时更改名称。
“名称”:“GCEC-FW.elf”
现在它抱怨 gdb 的路径。
新问题是:我可以在 VisualStudio 中输出或查看构建变量吗 - 比如
${workspaceRootFolderName}
或 ${env.gccpath}
关于 "...我可以在 VisualStudio 中输出或查看构建变量吗 - 比如: ${workspaceRootFolderName} or ${env.gccpath}
To display all of the currently available macros, in the Property
Pages dialog, under VC++ Directories, choose the drop-down arrow at
the end of a property row. Click on Edit and then in the edit dialog
box, choose the Macros button. The current set of properties and
macros visible to Visual Studio is listed along with the current value
for each. For more information, see the Specifying User-Defined Values
section of C++ project property page reference.
More here 关于那个。
我正在尝试在 VS 2019 中设置 Cmake ARM uC (STM32) 嵌入式项目。
项目构建正常,但我很难启动调试会话。
我已修改launch.vs.json
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "cppdbg",
"name": "GCEC-FW.elf",
"project": "out\build\IoT-Debug\GCEC-FW.elf",
"projectTarget": "",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}\BUILD\${workspaceRootFolderName}.elf",
"MIMode": "gdb",
"externalConsole": true,
"inheritEnvironments": [
"gcc_arm"
],
"miDebuggerPath": "${env.gccpath}\bin\arm-none-eabi-gdb.exe",
"setupCommands": [
{
"text": "-environment-cd ${workspaceRoot}/BUILD"
},
{
"text": "-file-exec-and-symbols ${workspaceRootFolderName}.elf",
"description": "load file",
"ignoreFailures": false
},
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"visualizerFile": "${debugInfo.linuxNatvisPath}",
"showDisplayString": true,
"miDebuggerServerAddress": "localhost:3333",
"launchCompleteCommand": "None",
"debugServerPath": "C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.3.0\Servers\J-Link_gdbserver\JLinkGDBServerCL.exe",
"debugServerArgs": "-port 2331 -s -CPU Cortex-M -device STM32F427II -endian little -speed 4000 -vd -swoport 2332",
"serverStarted": "GDB\ server\ started",
"filterStderr": true,
"filterStdout": true
}
]
}
但是当我尝试启动调试会话时,我收到错误消息,指出我的 .elf
文件不是 win32 可执行文件(实际上是正确的 - 它不是)。
问题是:VS 必须做什么才能开始这个会话?
编辑
我需要在添加附加新的微控制器调试配置时更改名称。 “名称”:“GCEC-FW.elf”
现在它抱怨 gdb 的路径。
新问题是:我可以在 VisualStudio 中输出或查看构建变量吗 - 比如
${workspaceRootFolderName}
或 ${env.gccpath}
关于 "...我可以在 VisualStudio 中输出或查看构建变量吗 - 比如: ${workspaceRootFolderName} or ${env.gccpath}
To display all of the currently available macros, in the Property Pages dialog, under VC++ Directories, choose the drop-down arrow at the end of a property row. Click on Edit and then in the edit dialog box, choose the Macros button. The current set of properties and macros visible to Visual Studio is listed along with the current value for each. For more information, see the Specifying User-Defined Values section of C++ project property page reference.
More here 关于那个。