Skip to content

GDB connection to OpenOCD server through localhost:3333 is not working anymore #6410

Description

@atrantan

Type: Debugger

Recent updates of cpptools or vscode "integrated debugger" make my GDB setup command -target-select remote localhost:3333 not working anymore. I'm using openocd as debug server and specify it using the debugServerPath entry in launch.json
For the moment, I need to downgrade to C/C++ Extension Version: v1.0.0 to make it work.

Describe the bug

  • OS and Version: Windows 10 (10.0.18362)
  • VS Code Version: 1.50.1 (system version)
  • C/C++ Extension Version: v1.1.0-insiders3
  • Other extensions you installed (and if the issue persists after disabling them):
    • CMake
    • CMake Tools
  • A clear and concise description of what the bug is.
    • Recent updates of cpptools or vscode "integrated debugger" make my GDB setup command -target-select remote localhost:3333 not working anymore. I'm using openocd as debug server and specify it using the debugServerPath entry in launch.json.
    • For the moment, I need to downgrade to C/C++ Extension Version: v1.0.0 to make it work.

To Reproduce
Please include a code sample and launch.json configuration.

My c++ code

// Copyright (c) 2020 Philippe COSTE
// Copyright (c) 2020 Antoine TRAN TAN
// Copyright (c) 2019 ARM Limited

#include "mbed.h"
#include "rtos.h"

// Blinking rate in milliseconds
#define BLINKING_RATE 500ms

int main()
{
    // Initialise the digital pin LED1 as an output
    DigitalOut led(LED1);

    while (true)
    {
        ThisThread::sleep_for(BLINKING_RATE);
    }
}

My launch.json file

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false,
            "debugServerArgs": "",
            "serverLaunchTimeout": 20000,
            "filterStderr": true,
            "filterStdout": false,
            "setupCommands": [
                { "text": "-environment-cd ${workspaceRoot}/build" },
                { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                { "text": "-file-exec-and-symbols IUT_NUCLEO_F429ZI", "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": "arm-none-eabi-gdb",
                "debugServerPath": "openocd",
                "debugServerArgs": "-f ${workspaceRoot}/st_nucleo_f4.cfg -c init -c \"reset init\""
            },
            "osx": {
                "MIMode": "gdb",
                "MIDebuggerPath": "arm-none-eabi-gdb",
                "debugServerPath": "openocd",
                "debugServerArgs": "-f ${workspaceRoot}/st_nucleo_f4.cfg -c init -c \"reset init\""
            },
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "arm-none-eabi-gdb.exe",
                "debugServerPath": "C:/OpenOCD/bin/openocd.exe",
                "debugServerArgs": "-f ${workspaceRoot}/st_nucleo_f4.cfg -c init -c \"reset init\"",
                "setupCommands": [
                    { "text": "-environment-cd ${workspaceRoot}\\build" },
                    { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                    { "text": "-file-exec-and-symbols IUT_NUCLEO_F429ZI", "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 }
                ]
            }
        }
    ]
}

Steps to reproduce the behavior:

  1. Click on the debugger icon at the left panel
  2. Click on the green "play" icon at the top left panel

Additional context

Output from debug console

1: (110) LaunchOptions{"name":"C++ Launch","type":"cppdbg","request":"launch","program":"C:\\Users\\antoi\\Desktop\\SNE\\IUT_NUCLEO_F429ZI\\build\\IUT_NUCLEO_F429ZI","args":[],"stopAtEntry":true,"cwd":"C:\\Users\\antoi\\Desktop\\SNE\\IUT_NUCLEO_F429ZI","environment":[],"externalConsole":false,"debugServerArgs":"-f C:\\Users\\antoi\\Desktop\\SNE\\IUT_NUCLEO_F429ZI/st_nucleo_f4.cfg -c init -c \"reset init\"","serverLaunchTimeout":20000,"filterStderr":true,"filterStdout":false,"setupCommands":[{"text":"-environment-cd C:\\Users\\antoi\\Desktop\\SNE\\IUT_NUCLEO_F429ZI\\build"},{"text":"-target-select remote localhost:3333","description":"connect to target","ignoreFailures":false},{"text":"-file-exec-and-symbols IUT_NUCLEO_F429ZI","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},"MIMode":"gdb","miDebuggerPath":"arm-none-eabi-gdb.exe","debugServerPath":"C:/OpenOCD/bin/openocd.exe","__sessionId":"8ae53742-d1fd-4817-92ee-35e086984a0f"}
1: (199) Wait for connection completion.
1: (705) ->=thread-group-added,id="i1"
1: (706) ->~"GNU gdb (GNU Arm Embedded Toolchain 9-2020-q2-update) 8.3.1.20191211-git\n"
1: (706) ->~"Copyright (C) 2019 Free Software Foundation, Inc.\n"
1: (706) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
1: (706) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
1: (706) ->~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\n"
1: (706) ->~"Type \"show configuration\" for configuration details.\n"
1: (706) ->~"For bug reporting instructions, please see:\n"
1: (706) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (706) ->~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
1: (707) ->~"\n\n"
1: (707) ->~"For help, type \"help\".\n"
1: (707) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (707) ->(gdb)
1: (713) <-1001-gdb-set target-async on
1: (715) ->1001^done
1: (715) ->(gdb)
1: (715) ->&"\n"
1: (715) ->^done
1: (715) ->(gdb)
1: (717) 1001: elapsed time 4
1: (724) <-1002-environment-cd C:\Users\antoi\Desktop\SNE\IUT_NUCLEO_F429ZI\build
1: (730) ->1002^done
1: (730) 1002: elapsed time 6
1: (730) ->(gdb)
1: (730) ->&"\n"
1: (731) ->^done
1: (731) ->(gdb)
1: (730) <-1003-target-select remote localhost:3333
1: (4781) ->1003^error,msg="localhost:3333: Aucune connexion n\222a pu \352tre \351tablie car l\222ordinateur cible l\222a express\351ment refus\351e."
1: (4781) ->(gdb)
1: (4782) ->&"\n"
1: (4783) ->^done
1: (4783) ->(gdb)
1: (4792) 1003: elapsed time 4062
1: (4806) Send Event AD7MessageEvent
1: (4806) <--gdb-exit
1: (4811) ->^exit
1: (4823) Send Event AD7ProgramDestroyEvent
The program 'C:\Users\antoi\Desktop\SNE\IUT_NUCLEO_F429ZI\build\IUT_NUCLEO_F429ZI' has exited with code 42 (0x0000002a).

Activity

  1. WardenGnaw commented on Oct 29, 2020

    @WardenGnaw
    Member

    I believe this is similar to #6411

    Thank you for using insiders and reporting the issue!

    We are currently investigating a fix at: microsoft/MIEngine#1070


    Side question:
    For your scenario, do you not use miDebuggerServerAddress because it does not use the correct MIDebuggerPath? Or do you prefer the launch.json to start your own debug server?

  2. atrantan commented on Oct 29, 2020

    @atrantan
    Author

    Andrew Wang (@WardenGnaw) my launch.json file is inspired from an auto-generated file from the online arm mbed compiler. But if the miDebuggerServerAddress makes the job, I'll use that

  3. WardenGnaw commented on Oct 29, 2020

    @WardenGnaw
    Member

    atrantan I will be closing this as duplicate of #6411

    We will have a fix for this issue the next release.

    Again, thank you for reporting this bug and using insiders!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions