{
	// 使用 IntelliSense 了解相关属性。
	// 悬停以查看现有属性的描述。
	// 欲了解更多信息，请访问: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [

		{ // 使用 JLinkGDBServer 的服务调试
			"name": "(gdb) JLinkGDBServer",
			"type": "cppdbg",
			"request": "launch",
			"program": "${workspaceFolder}/debug/project.elf",
			"args": [],
			"stopAtEntry": true,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": true,
			"MIMode": "gdb",
			// "miDebuggerPath": "gdb-multiarch",
			"miDebuggerPath": "arm-none-eabi-gdb",
			"miDebuggerServerAddress": "localhost:2331",
			"setupCommands": [
				{
					"description": "Enable pretty-printing for gdb",
					"text": "-enable-pretty-printing",
					"ignoreFailures": true
				}
			],
			"preLaunchTask": "JLinkGDBServer",
			"postDebugTask": "killallJLinkGDBServer",
		},

		{ // 直接仿真本机程序
			"name": "gdb",
			"type": "cppdbg",
			"request": "launch",
			"program": "${workspaceFolder}/debug/project.elf",
			"args": [],
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": false,
			"setupCommands": [
				{
					"description": "Enable pretty-printing for gdb",
					"text": "-enable-pretty-printing",
					"ignoreFailures": true
				}
			],
		},

		{ // 使用 qemu 远程调试
			"name": "(gdb) qemu-cm3",
			"type": "cppdbg",
			"request": "launch",
			"program": "${workspaceFolder}/debug/project.elf",
			"args": [],
			"stopAtEntry": true,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": true,
			"miDebuggerPath": "gdb-multiarch",
			"miDebuggerServerAddress": "localhost:1234",
			"setupCommands": [
				{
					"description": "Enable pretty-printing for gdb",
					"text": "-enable-pretty-printing",
					"ignoreFailures": true
				}
			],
			"preLaunchTask": "qemu",
			// "postDebugTask": "killallqemu",
		},

		{ // TODO: 使用 openocd 的服务调试，打印命令 openocd -f interface/jlink.cfg -f target/stm32f4x.cfg -c 'init' -c 'targets' -c 'reset halt'
			"name": "ARM Debug",
			"type": "cppdbg",
			"request": "launch",
			"miDebuggerPath": "gdb-multiarch",
			"targetArchitecture": "arm",
			"program": "${workspaceFolder}/debug/project.elf",
			"setupCommands": [
				{
					"text": "file '${workspaceFolder}/debug/project.elf'"
				},
				{
					"text": "target remote localhost:3333"
				},
				{
					"text": "monitor reset"
				},
				{
					"text": "monitor halt"
				},
				{
					"text": "load"
				}
			],
			//"preLaunchTask": "build",
			//"launchCompleteCommand": "None",
			//"externalConsole": true,
			"cwd": "${workspaceRoot}"
		},

	]
}
