PostFrontal Forum
PostFrontal Forum
LK8000_Support_Forum | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 LK8000 International Support
 Developers
 Experience with vscode and debug?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

mana
Pulcino

33 Posts

Posted - 30/06/2020 :  21:00:48  Show Profile  Reply with Quote
I'm new to modern development environments and started using vscode on Windows via WSL2 (my code and the build tools reside on Ubuntu, vscode runs on Windows 10) and after successfully modifying and building LK8000, I'm now trying to use the debug feature.

If one of you successfully used vscode in debug mode, do you mind sharing tips or guidelines? (I'm stuck properly modifying the launch.json)

BTW, as WSL2 doesn't natively support running GUI based linux apps, I'm thinking of doing the debug on the PC executable, though I'm not sure it would work. An alternative is to code in vscode, then get my code in Android Studio and debug from there.

brunotl
Pterodattilo

France
1095 Posts

Posted - 01/07/2020 :  12:34:37  Show Profile  Reply with Quote
this is my launch.json to debug PC target build with "cygwin_x86/mingw32".


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb)",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/LK8000-PC_debug-ns.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    "name": "PATH",
                    "value": "%PATH%;C:\\cygwin\\bin"
                }
            ],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\cygwin\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "gdb Pretty Printing",
                    "text": "-enable-pretty-printing -gdb-set detach-on-fork off",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

Go to Top of Page

mana
Pulcino

33 Posts

Posted - 01/07/2020 :  14:37:08  Show Profile  Reply with Quote
Thank you very much Bruno, I got it working just before seeing your post!

For anyone finding this thread & looking for similar information, I managed to run the LK8000 linux executable on Windows / WSL2. I installed X410 on Windows (x-terminal client), adjusted the DISPLAY variable on WSL to point to the correct IP address and now I can launch LK8000 (linux) that opens via X410 under Windows. I also managed to run the debugger in vscode / WSL2 with a launch.json almost identical to Bruno's:

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/LK8000-LINUX_debug-ns",   
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
			"miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build"            
        }
    ]
}


In tasks.json I also made a very simple build task, called through the launch.json via "preLaunchTask": "build" :

tasks.json
{
    "version": "2.0.0",
	"tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "make",
            "args": ["DEBUG=y"],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": "$gcc"
        }
    ]
}

So to validate my code tweaks I will keep using WSL2 rather than going the cygwin_x86/mingw32 or using a Linux VM or booting to Linux. I’m pretty pleased with WSL2, including build speed! To top it off Microsoft announced that later this year WSL2 will natively support launching GUI applications without installing a 3rd party X-terminal.

@brunotl, do you have a more fancy make/build tasks.json on vscode?

My current issue is the debugger sometimes telling me it doesn’t find a source file coming from an external library, eg :
Error: Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu-20.04/build/glibc-YYA7BZ/glibc-2.31/sysdeps/unix/sysv/linux/raise.c').

Is there a way to configure vscode to not try to step into external libraries in debug?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To:
PostFrontal Forum © PostFrontal - La community del Volo a Vela Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000

Since 2006, owned and maintained by PostFrontal S.A.S. di Giuliano Golfieri & c. - VAT ID: IT05264240960
THIS WEBSITE ONLY USES FUNCTIONAL COOKIES
Privacy & Cookie Policy