question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure debugger with VSCode

See original GitHub issue

Hi, I’m trying to configure debugger using Openocd 0.10.0 with VSCode from this reference on Windows 10. I can run Openocd and arm-none-eabi-gdb manually with exact configuration without any problem but on VS Code it seems that gdb debugger doesn’t run at all and only the debugger server runs. Here is launch.json that generated with mbed export.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/BUILD/ARCH_MAX/GCC_ARM/${workspaceRootFolderName}.elf",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false,
            "debugServerArgs": "-f interface/stlink-v2.cfg -f target/stm32f4x.cfg",
            "serverLaunchTimeout": 20000,
            "filterStderr": true,
            "filterStdout": false,
            "serverStarted": "GDB\\ server\\ started",
            "preLaunchTask": "mbed",
            "setupCommands": [
                { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                { "text": "-file-exec-and-symbols ${workspaceRoot}/BUILD/ARCH_MAX/GCC_ARM/${workspaceRootFolderName}.elf", "description": "load file", "ignoreFailures": false},
                { "text": "-interpreter-exec console \"monitor endian little\"", "ignoreFailures": false },
                { "text": "-interpreter-exec console \"monitor reset\"", "ignoreFailures": false },
                { "text": "-interpreter-exec console \"monitor halt\"", "ignoreFailures": false },
                { "text": "-interpreter-exec console \"monitor arm semihosting enable\"", "ignoreFailures": false },
                { "text": "-target-download", "description": "flash target", "ignoreFailures": false }
            ],
            "logging": {
                "moduleLoad": true,
                "trace": true,
                "engineLogging": true,
                "programOutput": true,
                "exceptions": true
            },
            "linux": {
                "MIMode": "gdb",
                "MIDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
                "debugServerPath": "pyocd-gdbserver"
            },
            "osx": {
                "MIMode": "gdb",
                "MIDebuggerPath": "/usr/local/bin/arm-none-eabi-gdb",
                "debugServerPath": "pyocd-gdbserver"
            },
            "windows": {
                "preLaunchTask": "mbed",
                "MIMode": "gdb",
                "MIDebuggerPath": "C:\\Program Files (x86)\\GNU Tools ARM Embedded\\7 2017-q4-major\\bin\\arm-none-eabi-gdb.exe",
                "debugServerPath": "C:\\openocd-0.10.0\\openocd-0.10.0\\bin-x64\\openocd.exe",
                "setupCommands": [
                    { "text": "-environment-cd ${workspaceRoot}\\BUILD\\ARCH_MAX\\GCC_ARM" },
                    { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                    { "text": "-file-exec-and-symbols ${workspaceRootFolderName}.elf", "description": "load file", "ignoreFailures": false},
                    { "text": "-interpreter-exec console \"monitor endian little\"", "ignoreFailures": false },
                    { "text": "-interpreter-exec console \"monitor reset\"", "ignoreFailures": false },
                    { "text": "-interpreter-exec console \"monitor halt\"", "ignoreFailures": false },
                    { "text": "-interpreter-exec console \"monitor arm semihosting enable\"", "ignoreFailures": false },
                    { "text": "-target-download", "description": "flash target", "ignoreFailures": false }
                ]
            }
        }
    ]
}

And tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "name": "mbed",
    "isShellCommand": true,
    "showOutput": "always",
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceRoot}/mbed-os"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    },
    "args": ["compile", "--profile=debug", "-t", "GCC_ARM", "-m", "ARCH_MAX"],
    "linux": {
        "command": "mbed"
    },
    "osx": {
        "command": "mbed"
    },
    "windows": {
        "command": "mbed"
    }
}

And here is the output log on debugger:

1: (163) LaunchOptions<LocalLaunchOptions xmlns=‘http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014’ 1: (173) LaunchOptions ExePath=‘C:\Users\Masoud\Desktop\mbed_test\mbed-os-example-blinky\BUILD\ARCH_MAX\GCC_ARM\mbed-os-example-blinky.elf’ 1: (173) LaunchOptions WorkingDirectory=‘C:\Users\Masoud\Desktop\mbed_test\mbed-os-example-blinky’ 1: (173) LaunchOptions ExeArguments=‘’ 1: (173) LaunchOptions MIMode=‘gdb’ 1: (173) LaunchOptions MIDebuggerPath=‘C:\Program Files (x86)\GNU Tools ARM Embedded\7 2017-q4-major\bin\arm-none-eabi-gdb.exe’ 1: (173) LaunchOptions WaitDynamicLibLoad=‘false’ 1: (173) LaunchOptions DebugServer=‘C:\openocd-0.10.0\openocd-0.10.0\bin-x64\openocd.exe’ 1: (173) LaunchOptions DebugServerArgs=‘-f interface/stlink-v2.cfg -f target/stm32f4x.cfg’ 1: (173) LaunchOptions ServerStarted=‘GDB\ server\ started’ 1: (173) LaunchOptions FilterStderr=‘true’ 1: (173) LaunchOptions ServerLaunchTimeout=‘20000’ 1: (173) LaunchOptions> 1: (173) LaunchOptions <SetupCommands> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description=''>-environment-cd C:\Users\Masoud\Desktop\mbed_test\mbed-os-example-blinky\BUILD\ARCH_MAX\GCC_ARM</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description='connect to target'>-target-select remote localhost:3333</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description='load file'>-file-exec-and-symbols C:\Users\Masoud\Desktop\mbed_test\mbed-os-example-blinky/BUILD/ARCH_MAX/GCC_ARM/mbed-os-example-blinky.elf</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description=''>-interpreter-exec console “monitor endian little”</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description=''>-interpreter-exec console “monitor reset”</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description=''>-interpreter-exec console “monitor halt”</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description=''>-interpreter-exec console “monitor arm semihosting enable”</Command> 1: (173) LaunchOptions <Command IgnoreFailures='false' Description='flash target'>-target-download</Command> 1: (173) LaunchOptions </SetupCommands> 1: (173) LaunchOptions</LocalLaunchOptions> 1: (225) Starting: “C:\openocd-0.10.0\openocd-0.10.0\bin-x64\openocd.exe” -f interface/stlink-v2.cfg -f target/stm32f4x.cfg 1: (20237) <-logout

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
0Gritcommented, Jun 29, 2018

@masoudr This repo or the mbed-os repo are probably was the correct location for this particular issue.

My comment was in regard to your earlier statement

I think the documentation should be fixed for this. It didn’t say anything about serverStarted command for OpenOCD.

1reaction
janjongboomcommented, Jun 27, 2018

@masoudr See https://gist.github.com/janjongboom/51f2edbee8c965741465fa5feefe4cf1 - the serverStarted command needs to be different for OpenOCD and the serverArgs need to have the full path I believe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Introduction to Debugging in Visual Studio Code
Debugging is a core feature of Visual Studio Code. Learn how to configure and use the Node.js debugger in this introductory video.
Read more >
Configure launch.json for C/C++ debugging in Visual Studio ...
A launch.json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch.json (under a .vscode folder...
Read more >
Debugging configurations for Python apps in Visual Studio Code
Switch to the Run and Debug view (Ctrl+Shift+D), select the appropriate configuration from the debugger dropdown list, and start the debugger. The debugger...
Read more >
Debugger Extension - Visual Studio Code
Visual Studio Code's debugging architecture allows extension authors to easily integrate existing debuggers into VS Code, while having a common user interface ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found