Skip to content
Jean-Sébastien Nadeau edited this page Jul 14, 2020 · 6 revisions

Supported defaults:

The best way to debug is by using the C/C++ IDE's (Visual Studio, Xcode, Clion, Code::Blocks,...) supported by Kinc/kincmake.

Custom setups:

As of the time of writing this, the most supported default debugging scheme is using C/C++ IDE's. But you can debug with other editors when configuring things by yourself. These are the ways people from the community have been able to setup debug setup's for different editor's. If ever you found a better way to do it we invite you to share for others.

Debugging with VSCode:

For debugging in VSCode 2 extensions are available either Microsoft's or Native Debug. For this example, Native Debug was used.

Start by adding a tasks.json like so:

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "shell",
			"label": "Debug Build",
			"command": "make",
			"options": {
				"cwd": "${workspaceFolder}/build/Debug"
			},
			"problemMatcher": [
				"$gcc"
			]
		},
		{
			"type":"shell",
			"label": "Build",
			"command": "mv",
			"args": [
				"${workspaceFolder}/build/Debug/Project-Name",
				"${workspaceFolder}/Deployment"
			],
			"dependsOn":[
				"Build Project"
			],
		},
		{
			"type": "shell",
			"label": "Remove *.o",
			"command": "rm *.o",
			"options": {
				"cwd": "${workspaceFolder}/build/Debug"
			},
			"problemMatcher": [
				"$gcc"
			]
		},
		{
			"type": "shell",
			"label": "Clean Build",
			"command": "node Kinc/make --debug --compiler clang",
			"options": {
				"cwd": "${workspaceFolder}"
			},
			"dependsOn":[
				"Remove *.o"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
		}

	]
}

Then we create a launch.json that looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "gdb",
            "request": "launch",
            "target": "${workspaceFolder}/Deployment/Project-Name",
            "cwd": "${workspaceFolder}/Deployment",
            "valuesFormatting": "parseText",
            "preLaunchTask": "Build"
        }
    ]
}

Be sure to change every occurrence of Project-Name with the name of your project. Also, make sure to have a Deployment folder at the root of the Project.

Clone this wiki locally