Vscode-cpptools: [Help] Troubles configuring launch.json for remote debugger

Created on 29 Sep 2016  路  13Comments  路  Source: microsoft/vscode-cpptools

Linux 14.04
Version 1.5.3
Commit 5be4091987a98e3870d89d630eb87be6d9bafd27
Date 2016-09-22T08:40:08.699Z
Shell 0.37.6
Renderer 49.0.2623.75
Node 5.10.0
C/C++ 0.9.2

My remote gdb-server (pyocd) uses USB and requires sudo. I created a udev rule to allow sudo access to the server but when running from vscode it seems this permission isn't allowed. Is there a way to run the gdb-server as sudo or get a prompt for the password? Otherwise I have to use the console to start the server and then launch the debugger. Here is my launch.json for reference.

The error is Unable to start debugging. Debug server process failed to initialize.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/.build/k64f/gcc_arm/mbed-os-example-blinky.elf",
            "args": ["target remote localhost:3333"],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "miDebuggerServerAddress": "localhost:3333",
            "serverStarted": "None",
            "debugServerArgs": "",
            "serverLaunchTimeout": 5000,
            "linux": {
                "MIMode": "gdb",
                "MIDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
                "debugServerPath": "/usr/local/bin/pyocd-gdbserver"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}

Removing "debugServerPath": "/usr/local/bin/pyocd-gdbserver" and starting the server in the console with pyocd-gdbserver works fine.

samgro01@ubuntu:~/Desktop/tmp/mbed-os-example-blinky$ pyocd-gdbserver                                         
INFO:root:new board id detected: 90090203E062F2821D9E9D73                                                     
INFO:root:board allows 1 concurrent packets                                                                   
INFO:root:DAP SWD MODE initialised                                                                            
INFO:root:IDCODE: 0xBB11477                                                                                   
INFO:root:4 hardware breakpoints, 0 literal comparators                                                       
INFO:root:CPU core is Cortex-M0                                                                               
INFO:root:2 hardware watchpoints                                                                              
INFO:root:Telnet: server started on port 4444                                                                 
INFO:root:GDB server started at port:3333                                                                     
None                                                                                                          
INFO:root:One client connected!                                                                               
INFO:root:GDB server started at port:3333                                                                     
None  
...
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
0x00002a44 in SDHC_TransferHandleIRQ ()
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
Note: automatically using hardware breakpoints for read-only addresses.

and the udev rule in /etc/udev/rules.d/pyocd.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="0d28", ATTR{idProduct}=="0204", MODE="666"
debugger question

Most helpful comment

Looks like the solution for me is 2 fold.

  • serverStarted seems to be required.
  • filterStderr must be true. Seems this is causing conflict on the match with serverStarted
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/.build/k64f/gcc_arm/mbed-os-example-blinky.elf",
            "args": ["target remote localhost:3333"],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIDebuggerServerAddress": "localhost:3333",
            "debugServerArgs": "",
            "serverLaunchTimeout": 5000,
            "filterStderr": true,
            "filterStdout": false,
            "serverStarted": "GDB\\ server\\ started",
            "logging": {
                "moduleLoad": true,
                "trace": true,
                "engineLogging": true,
                "programOutput": true,
                "exceptions": true
            },
            "linux": {
                "MIMode": "gdb",
                "MIDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
                "debugServerPath": "/usr/local/bin/pyocd-gdbserver"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}

results in:

1: (157) LaunchOptions  ExePath='/home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm/mbed-os-example-blinky.elf'
1: (157) LaunchOptions  WorkingDirectory='/home/samgro01/Desktop/tmp/mbed-os-example-blinky'
1: (157) LaunchOptions  ExeArguments='"target remote localhost:3333"'
1: (157) LaunchOptions MIMode='gdb'
1: (157) LaunchOptions  MIDebuggerPath='/usr/bin/arm-none-eabi-gdb'
1: (157) LaunchOptions  WaitDynamicLibLoad='false'
1: (157) LaunchOptions  MIDebuggerServerAddress='localhost:3333'
1: (157) LaunchOptions  DebugServer='/usr/local/bin/pyocd-gdbserver'
1: (157) LaunchOptions  DebugServerArgs=''
1: (157) LaunchOptions  ServerStarted='GDB\ server\ started'
1: (157) LaunchOptions  FilterStderr='true'
1: (157) LaunchOptions  ServerLaunchTimeout='5000'
1: (157) LaunchOptions  ExternalConsole='true'
1: (157) LaunchOptions>
1: (157) LaunchOptions</LocalLaunchOptions>
1: (213) Starting: "/usr/local/bin/pyocd-gdbserver" 
1: (441) Starting: "/usr/bin/arm-none-eabi-gdb" --interpreter=mi
1: (465) DebuggerPid=12014
1: (481) ->=thread-group-added,id="i1"
1: (483) ->~"GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n"
1: (483) ->~"Copyright (C) 2014 Free Software Foundation, Inc.\n"
1: (484) ->~"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.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (484) ->~"This GDB was configured as \"--host=x86_64-unknown-linux-gnu --target=arm-none-eabi\".\nType \"show configuration\" for configuration details."
1: (484) ->~"\nFor bug reporting instructions, please see:\n"
1: (484) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (484) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (485) ->~"For help, type \"help\".\n"
1: (485) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (485) ->(gdb)
1: (487) <-1001-gdb-set target-async on
1: (488) ->1001^done
1: (488) ->(gdb)
1: (489) 1001: elapsed time 2
1: (494) <-1002-gdb-set solib-search-path /home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm:
1: (494) ->1002^done
1: (494) ->(gdb)
1: (494) 1002: elapsed time 0
1: (494) <-1003-environment-cd /home/samgro01/Desktop/tmp/mbed-os-example-blinky
1: (495) ->1003^done
1: (495) ->(gdb)
1: (495) 1003: elapsed time 0
1: (495) <-1004-file-exec-and-symbols /home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm/mbed-os-example-blinky.elf
1: (504) ->1004^done
1: (505) ->(gdb)
1: (505) 1004: elapsed time 10
1: (507) <-1005-interpreter-exec console "show architecture"
1: (507) ->~"The target architecture is set automatically (currently arm)\n"
1: (507) ->1005^done
1: (507) ->(gdb)
1: (508) 1005: elapsed time 0
1: (511) <-1006-exec-arguments "target remote localhost:3333"
1: (512) ->1006^done
1: (512) ->(gdb)
1: (512) 1006: elapsed time 0
1: (512) <-1007-break-insert main
1: (512) ->1007^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000018aa",func="main()",file="./main.cpp",fullname="/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp",line="9",thread-groups=["i1"],times="0",original-location="main"}
1: (513) ->(gdb)
1: (514) 1007: elapsed time 2
1: (514) <-1008-target-select remote localhost:3333
1: (607) ->=thread-group-started,id="i1",pid="42000"
1: (607) ->=thread-created,id="1",group-id="i1"
1: (668) ->~"0x0001cf3e in ?? ()\n"
1: (668) ->*stopped,frame={addr="0x0001cf3e",func="??",args=[]},thread-id="1",stopped-threads="all",core="0"
1: (669) ->1008^connected
1: (669) ->(gdb)
1: (675) 1008: elapsed time 160
C setBreakpoints: {"source":{"path":"/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp","name":"main.cpp"},"lines":[9],"breakpoints":[{"line":9}],"sourceModified":false}
1: (713) <-1009-break-insert -f main.cpp:9
1: (740) ->1009^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x000018aa",func="main()",file="./main.cpp",fullname="/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp",line="9",thread-groups=["i1"],times="0",original-location="main.cpp:9"}
1: (740) ->(gdb)
1: (740) 1009: elapsed time 27
1: (746) <-1010-symbol-list-lines main.cpp
1: (747) ->1010^done,lines=[{pc="0x000018a8",line="7"},{pc="0x000018aa",line="9"},{pc="0x000018c4",line="10"},{pc="0x000018cc",line="7"},{pc="0x000018d4",line="0"},{pc="0x000018d4",line="12"},{pc="0x000018dc",line="12"},{pc="0x000018ec",line="3"},{pc="0x000018f6",line="12"},{pc="0x00001900",line="0"},{pc="0x00001900",line="12"},{pc="0x00001902",line="12"},{pc="0x0000190e",line="0"}]
1: (747) ->(gdb)
1: (748) 1010: elapsed time 1
C setFunctionBreakpoints: {"breakpoints":[]}
C configurationDone: null
pyocd-gdbserver: INFO:root:DAP SWD MODE initialised
pyocd-gdbserver: INFO:root:ROM table #0 @ 0xf0000000 cidr=b105100d pidr=2009c4001
pyocd-gdbserver: INFO:root:[0]<e00ff000: cidr=b105100d, pidr=4000bb471, class=1>
pyocd-gdbserver: INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471
pyocd-gdbserver: INFO:root:[0]<e000e000:SCS-M0+ cidr=b105e00d, pidr=4000bb008, class=14>
pyocd-gdbserver: INFO:root:[1]<e0001000:DWT-M0+ cidr=b105e00d, pidr=4000bb00a, class=14>
pyocd-gdbserver: INFO:root:[2]<e0002000:BPU cidr=b105e00d, pidr=4000bb00b, class=14>
pyocd-gdbserver: INFO:root:[1]<f0002000: cidr=b105900d, pidr=4000bb9a3, class=9, devtype=13, devid=0>
pyocd-gdbserver: INFO:root:CPU core is Cortex-M0
pyocd-gdbserver: INFO:root:4 hardware breakpoints, 0 literal comparators
pyocd-gdbserver: INFO:root:2 hardware watchpoints
pyocd-gdbserver: INFO:root:Telnet: server started on port 4444
pyocd-gdbserver: INFO:root:GDB server started at port:3333
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
pyocd-gdbserver: INFO:root:One client connected!
0x0001cf3e in ?? ()
1: (775) <-1011-interpreter-exec console "info sharedlibrary"
1: (775) ->~"No shared libraries loaded at this time.\n"
1: (775) ->1011^done
1: (776) ->(gdb)
1: (776) 1011: elapsed time 1
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
1: (786) <-1012-thread-info
1: (809) ->1012^done,threads=[{id="1",target-id="Thread 1",details="Thread mode",frame={level="0",addr="0x0001cf3e",func="??",args=[]},state="stopped",core="0"}],current-thread-id="1"
1: (809) ->(gdb)
1: (809) 1012: elapsed time 23
1: (819) <-1013-stack-list-frames 0 1000
1: (839) ->1013^done,stack=[frame={level="0",addr="0x0001cf3e",func="??"},frame={level="1",addr="0x0001ccf6",func="??"}]
1: (840) ->(gdb)
1: (840) 1013: elapsed time 21
C threads: null
1: (848) <--exec-continue
1: (849) ->~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
1: (857) ->^running
1: (857) ->*running,thread-id="all"
1: (857) ->(gdb)
1: (858) ->(gdb)

All 13 comments

@sg- Unfortunately, vscode does not pass security attributes to child processes, which makes it difficult for the debugger to get the permissions correct for all situations.

However, you may not need to launch using gdb server here. If you need to use GDB server on the "remote side", you might be able to launch your remote program, and use the "attach" configuration to attach to gdb server using gdb.

@edumunoz , can you offer some help here?

From my understanding, this doesn't necessarily have to be a permissions issue. Due to the udev rule, your user has permission to the USB device, so I assume the process that VSCode executes does too.

A possible issue has to do with the pattern that you have specified in launch.json. From looking at the code, I can see that the extension will wait until that pattern is received from the server (in your case, "None") for 5 seconds (according to your launch.json). Is that timeout enough in your scenario?

@paulmaybee probably has more details and can help more than I can.

In case you want to tinker with the code, check these two places
https://github.com/Microsoft/MIEngine/blob/master/src/MICore/Transports/ClientServerTransport.cs#L43
https://github.com/Microsoft/MIEngine/blob/master/src/MICore/Transports/ServerTransport.cs#L46

A possible issue has to do with the pattern that you have specified in launch.json. From looking at the code, I can see that the extension will wait until that pattern is received from the server (in your case, "None") for 5 seconds (according to your launch.json). Is that timeout enough in your scenario?

I've tried with no pattern as well. What I found odd was that launching the gdbserver in a separate console, the gdb client found it and attached even though the pattern would have already been printed to the console. This is achieved by:

Removing "debugServerPath": "/usr/local/bin/pyocd-gdbserver" and starting the server in the console with pyocd-gdbserver.

How does the launcher determine the server process has started? Read a string from stdout??

@edumunoz @paulmaybee Do you have an answer to @sg's question?

I'm not super familiar with this code, but frommy understanding from reading the code (as pointed in the second link of my previous comment), it seems like MIEngine reads from stdout and signals StartedEvent when the pattern matches a line.

The first link in my comment points to the part of the code that waits for StartedEvent. The error message used if StartedEvent is not set within the timeout period is the error you are seeing

Debug server process failed to initialize.

If @paulmaybee can't help, we can try to set up a repro and debug MIEngine to see what's happening.

However, you may not need to launch using gdb server here. If you need to use GDB server on the "remote side", you might be able to launch your remote program, and use the "attach" configuration to attach to gdb server using gdb.

Could you provide an example of how I'd try this?

bump

Edit: I've added the logging.

            "logging": {
                "moduleLoad": true,
                "trace": true,
                "engineLogging": true,
                "programOutput": true,
                "exceptions": true
            },

and the log

1: (154) LaunchOptions</LocalLaunchOptions>
1: (213) Starting: "/usr/local/bin/pyocd-gdbserver" 
1: (353) STDERR: INFO:root:DAP SWD MODE initialised
1: (399) STDERR: INFO:root:ROM table #0 @ 0xf0000000 cidr=b105100d pidr=2009c4001
1: (406) STDERR: INFO:root:[0]<e00ff000: cidr=b105100d, pidr=4000bb471, class=1>
1: (410) STDERR: INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471
1: (419) STDERR: INFO:root:[0]<e000e000:SCS-M0+ cidr=b105e00d, pidr=4000bb008, class=14>
1: (423) STDERR: INFO:root:[1]<e0001000:DWT-M0+ cidr=b105e00d, pidr=4000bb00a, class=14>
1: (427) STDERR: INFO:root:[2]<e0002000:BPU cidr=b105e00d, pidr=4000bb00b, class=14>
1: (434) STDERR: INFO:root:[1]<f0002000: cidr=b105900d, pidr=4000bb9a3, class=9, devtype=13, devid=0>
1: (442) STDERR: INFO:root:CPU core is Cortex-M0
1: (446) STDERR: INFO:root:4 hardware breakpoints, 0 literal comparators
1: (454) STDERR: INFO:root:2 hardware watchpoints
1: (467) STDERR: INFO:root:Telnet: server started on port 4444
1: (467) STDERR: INFO:root:GDB server started at port:3333
1: (5226) <-logout
C disconnect: {"restart":false}

Sorry, somehow missed this thread earlier.
Have you tried starting the gdbserver "by hand" on the target device: gdbserver localhost:2345 a.out
Then set this value in the launch.json: "miDebuggerServerAddress": "your-machine-name:2345"
Then just launch as normal?

Yep - Removing "debugServerPath": "/usr/local/bin/pyocd-gdbserver" and starting the server in the console with pyocd-gdbserver works fine.


samgro01@ubuntu:~/Desktop/tmp/mbed-os-example-blinky$ pyocd-gdbserver
INFO:root:DAP SWD MODE initialised
INFO:root:ROM table #0 @ 0xf0000000 cidr=b105100d pidr=2009c4001
INFO:root:[0]<e00ff000: cidr=b105100d, pidr=4000bb471, class=1>
INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471
INFO:root:[0]<e000e000:SCS-M0+ cidr=b105e00d, pidr=4000bb008, class=14>
INFO:root:[1]<e0001000:DWT-M0+ cidr=b105e00d, pidr=4000bb00a, class=14>
INFO:root:[2]<e0002000:BPU cidr=b105e00d, pidr=4000bb00b, class=14>
INFO:root:[1]<f0002000: cidr=b105900d, pidr=4000bb9a3, class=9, devtype=13, devid=0>
INFO:root:CPU core is Cortex-M0
INFO:root:4 hardware breakpoints, 0 literal comparators
INFO:root:2 hardware watchpoints
INFO:root:Telnet: server started on port 4444
INFO:root:GDB server started at port:3333

... Click debug ...

1: (150) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (156) LaunchOptions  ExePath='/home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm/mbed-os-example-blinky.elf'
1: (156) LaunchOptions  WorkingDirectory='/home/samgro01/Desktop/tmp/mbed-os-example-blinky'
1: (156) LaunchOptions  ExeArguments='"target remote localhost:3333"'
1: (156) LaunchOptions MIMode='gdb'
1: (157) LaunchOptions  MIDebuggerPath='/usr/bin/arm-none-eabi-gdb'
1: (157) LaunchOptions  WaitDynamicLibLoad='false'
1: (157) LaunchOptions  MIDebuggerServerAddress='localhost:3333'
1: (157) LaunchOptions  DebugServerArgs=''
1: (157) LaunchOptions  ServerStarted=''
1: (157) LaunchOptions  ServerLaunchTimeout='5000'
1: (157) LaunchOptions  ExternalConsole='true'
1: (157) LaunchOptions>
1: (157) LaunchOptions</LocalLaunchOptions>
1: (227) Starting: "/usr/bin/arm-none-eabi-gdb" --interpreter=mi
1: (255) DebuggerPid=5658
1: (351) ->=thread-group-added,id="i1"
1: (352) ->~"GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n"
1: (352) ->~"Copyright (C) 2014 Free Software Foundation, Inc.\n"
1: (352) ->~"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.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (352) ->~"This GDB was configured as \"--host=x86_64-unknown-linux-gnu --target=arm-none-eabi\".\nType \"show configuration\" for configuration details."
1: (352) ->~"\nFor bug reporting instructions, please see:\n"
1: (352) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (352) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (352) ->~"For help, type \"help\".\n"
1: (352) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (352) ->(gdb)
1: (356) <-1001-gdb-set target-async on
1: (356) ->1001^done
1: (356) ->(gdb)
1: (357) 1001: elapsed time 2
1: (362) <-1002-gdb-set solib-search-path /home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm:
1: (363) ->1002^done
1: (363) ->(gdb)
1: (363) 1002: elapsed time 0
1: (363) <-1003-environment-cd /home/samgro01/Desktop/tmp/mbed-os-example-blinky
1: (363) ->1003^done
1: (363) ->(gdb)
1: (363) 1003: elapsed time 0
1: (363) <-1004-file-exec-and-symbols /home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm/mbed-os-example-blinky.elf
1: (384) ->1004^done
1: (384) ->(gdb)
1: (384) 1004: elapsed time 20
1: (385) <-1005-interpreter-exec console "show architecture"
1: (385) ->~"The target architecture is set automatically (currently arm)\n"
1: (386) ->1005^done
1: (386) ->(gdb)
1: (386) 1005: elapsed time 0
1: (388) <-1006-exec-arguments "target remote localhost:3333"
1: (389) ->1006^done
1: (389) ->(gdb)
1: (389) 1006: elapsed time 0
1: (389) <-1007-break-insert main
1: (392) ->1007^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000018aa",func="main()",file="./main.cpp",fullname="/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp",line="9",thread-groups=["i1"],times="0",original-location="main"}
1: (392) ->(gdb)
1: (394) 1007: elapsed time 5
1: (394) <-1008-target-select remote localhost:3333
1: (485) ->=thread-group-started,id="i1",pid="42000"
1: (485) ->=thread-created,id="1",group-id="i1"
1: (542) ->~"0x0001c1fe in ?? ()\n"
1: (542) ->*stopped,frame={addr="0x0001c1fe",func="??",args=[]},thread-id="1",stopped-threads="all",core="0"
1: (543) ->1008^connected
1: (543) ->(gdb)
1: (547) 1008: elapsed time 152
C setBreakpoints: {"source":{"path":"/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp","name":"main.cpp"},"lines":[9],"breakpoints":[{"line":9}],"sourceModified":false}
1: (590) <-1009-break-insert -f main.cpp:9
1: (618) ->1009^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x000018aa",func="main()",file="./main.cpp",fullname="/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp",line="9",thread-groups=["i1"],times="0",original-location="main.cpp:9"}
1: (618) ->(gdb)
1: (618) 1009: elapsed time 28
1: (626) <-1010-symbol-list-lines main.cpp
1: (626) ->1010^done,lines=[{pc="0x000018a8",line="7"},{pc="0x000018aa",line="9"},{pc="0x000018c4",line="10"},{pc="0x000018cc",line="7"},{pc="0x000018d4",line="0"},{pc="0x000018d4",line="12"},{pc="0x000018dc",line="12"},{pc="0x000018ec",line="3"},{pc="0x000018f6",line="12"},{pc="0x00001900",line="0"},{pc="0x00001900",line="12"},{pc="0x00001902",line="12"},{pc="0x0000190e",line="0"}]
1: (626) ->(gdb)
1: (627) 1010: elapsed time 1
C setFunctionBreakpoints: {"breakpoints":[]}
C configurationDone: null
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
0x0001c1fe in ?? ()
1: (651) <-1011-interpreter-exec console "info sharedlibrary"
1: (652) ->~"No shared libraries loaded at this time.\n"
1: (652) ->1011^done
1: (652) ->(gdb)
1: (652) 1011: elapsed time 0
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
1: (662) <-1012-thread-info
1: (684) ->1012^done,threads=[{id="1",target-id="Thread 1",details="Thread mode",frame={level="0",addr="0x0001c1fe",func="??",args=[]},state="stopped",core="0"}],current-thread-id="1"
1: (684) ->(gdb)
1: (684) 1012: elapsed time 22
1: (691) <-1013-stack-list-frames 0 1000
1: (698) ->1013^done,stack=[frame={level="0",addr="0x0001c1fe",func="??"},frame={level="1",addr="0x0001c1b8",func="??"}]
1: (698) ->(gdb)
1: (699) 1013: elapsed time 7
C threads: null
1: (708) <--exec-continue
1: (708) ->~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
1: (714) ->^running
1: (714) ->*running,thread-id="all"
1: (714) ->(gdb)
1: (715) ->(gdb)

Ok, then have you tried using the

"debugServerPath": "/usr/local/bin/pyocd-gdbserver",
"filterStderr":"true",
"filterStdout":"false",
"serverStarted":"GDB\ server\ started"

could also adjust "serverLaunchTimeout" if the default 10 seconds is not long enough?

should be double backslashes in above serverStarted string

Looks like the solution for me is 2 fold.

  • serverStarted seems to be required.
  • filterStderr must be true. Seems this is causing conflict on the match with serverStarted
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/.build/k64f/gcc_arm/mbed-os-example-blinky.elf",
            "args": ["target remote localhost:3333"],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIDebuggerServerAddress": "localhost:3333",
            "debugServerArgs": "",
            "serverLaunchTimeout": 5000,
            "filterStderr": true,
            "filterStdout": false,
            "serverStarted": "GDB\\ server\\ started",
            "logging": {
                "moduleLoad": true,
                "trace": true,
                "engineLogging": true,
                "programOutput": true,
                "exceptions": true
            },
            "linux": {
                "MIMode": "gdb",
                "MIDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
                "debugServerPath": "/usr/local/bin/pyocd-gdbserver"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}

results in:

1: (157) LaunchOptions  ExePath='/home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm/mbed-os-example-blinky.elf'
1: (157) LaunchOptions  WorkingDirectory='/home/samgro01/Desktop/tmp/mbed-os-example-blinky'
1: (157) LaunchOptions  ExeArguments='"target remote localhost:3333"'
1: (157) LaunchOptions MIMode='gdb'
1: (157) LaunchOptions  MIDebuggerPath='/usr/bin/arm-none-eabi-gdb'
1: (157) LaunchOptions  WaitDynamicLibLoad='false'
1: (157) LaunchOptions  MIDebuggerServerAddress='localhost:3333'
1: (157) LaunchOptions  DebugServer='/usr/local/bin/pyocd-gdbserver'
1: (157) LaunchOptions  DebugServerArgs=''
1: (157) LaunchOptions  ServerStarted='GDB\ server\ started'
1: (157) LaunchOptions  FilterStderr='true'
1: (157) LaunchOptions  ServerLaunchTimeout='5000'
1: (157) LaunchOptions  ExternalConsole='true'
1: (157) LaunchOptions>
1: (157) LaunchOptions</LocalLaunchOptions>
1: (213) Starting: "/usr/local/bin/pyocd-gdbserver" 
1: (441) Starting: "/usr/bin/arm-none-eabi-gdb" --interpreter=mi
1: (465) DebuggerPid=12014
1: (481) ->=thread-group-added,id="i1"
1: (483) ->~"GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n"
1: (483) ->~"Copyright (C) 2014 Free Software Foundation, Inc.\n"
1: (484) ->~"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.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (484) ->~"This GDB was configured as \"--host=x86_64-unknown-linux-gnu --target=arm-none-eabi\".\nType \"show configuration\" for configuration details."
1: (484) ->~"\nFor bug reporting instructions, please see:\n"
1: (484) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (484) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (485) ->~"For help, type \"help\".\n"
1: (485) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (485) ->(gdb)
1: (487) <-1001-gdb-set target-async on
1: (488) ->1001^done
1: (488) ->(gdb)
1: (489) 1001: elapsed time 2
1: (494) <-1002-gdb-set solib-search-path /home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm:
1: (494) ->1002^done
1: (494) ->(gdb)
1: (494) 1002: elapsed time 0
1: (494) <-1003-environment-cd /home/samgro01/Desktop/tmp/mbed-os-example-blinky
1: (495) ->1003^done
1: (495) ->(gdb)
1: (495) 1003: elapsed time 0
1: (495) <-1004-file-exec-and-symbols /home/samgro01/Desktop/tmp/mbed-os-example-blinky/.build/k64f/gcc_arm/mbed-os-example-blinky.elf
1: (504) ->1004^done
1: (505) ->(gdb)
1: (505) 1004: elapsed time 10
1: (507) <-1005-interpreter-exec console "show architecture"
1: (507) ->~"The target architecture is set automatically (currently arm)\n"
1: (507) ->1005^done
1: (507) ->(gdb)
1: (508) 1005: elapsed time 0
1: (511) <-1006-exec-arguments "target remote localhost:3333"
1: (512) ->1006^done
1: (512) ->(gdb)
1: (512) 1006: elapsed time 0
1: (512) <-1007-break-insert main
1: (512) ->1007^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000018aa",func="main()",file="./main.cpp",fullname="/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp",line="9",thread-groups=["i1"],times="0",original-location="main"}
1: (513) ->(gdb)
1: (514) 1007: elapsed time 2
1: (514) <-1008-target-select remote localhost:3333
1: (607) ->=thread-group-started,id="i1",pid="42000"
1: (607) ->=thread-created,id="1",group-id="i1"
1: (668) ->~"0x0001cf3e in ?? ()\n"
1: (668) ->*stopped,frame={addr="0x0001cf3e",func="??",args=[]},thread-id="1",stopped-threads="all",core="0"
1: (669) ->1008^connected
1: (669) ->(gdb)
1: (675) 1008: elapsed time 160
C setBreakpoints: {"source":{"path":"/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp","name":"main.cpp"},"lines":[9],"breakpoints":[{"line":9}],"sourceModified":false}
1: (713) <-1009-break-insert -f main.cpp:9
1: (740) ->1009^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x000018aa",func="main()",file="./main.cpp",fullname="/home/samgro01/Desktop/tmp/mbed-os-example-blinky/main.cpp",line="9",thread-groups=["i1"],times="0",original-location="main.cpp:9"}
1: (740) ->(gdb)
1: (740) 1009: elapsed time 27
1: (746) <-1010-symbol-list-lines main.cpp
1: (747) ->1010^done,lines=[{pc="0x000018a8",line="7"},{pc="0x000018aa",line="9"},{pc="0x000018c4",line="10"},{pc="0x000018cc",line="7"},{pc="0x000018d4",line="0"},{pc="0x000018d4",line="12"},{pc="0x000018dc",line="12"},{pc="0x000018ec",line="3"},{pc="0x000018f6",line="12"},{pc="0x00001900",line="0"},{pc="0x00001900",line="12"},{pc="0x00001902",line="12"},{pc="0x0000190e",line="0"}]
1: (747) ->(gdb)
1: (748) 1010: elapsed time 1
C setFunctionBreakpoints: {"breakpoints":[]}
C configurationDone: null
pyocd-gdbserver: INFO:root:DAP SWD MODE initialised
pyocd-gdbserver: INFO:root:ROM table #0 @ 0xf0000000 cidr=b105100d pidr=2009c4001
pyocd-gdbserver: INFO:root:[0]<e00ff000: cidr=b105100d, pidr=4000bb471, class=1>
pyocd-gdbserver: INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471
pyocd-gdbserver: INFO:root:[0]<e000e000:SCS-M0+ cidr=b105e00d, pidr=4000bb008, class=14>
pyocd-gdbserver: INFO:root:[1]<e0001000:DWT-M0+ cidr=b105e00d, pidr=4000bb00a, class=14>
pyocd-gdbserver: INFO:root:[2]<e0002000:BPU cidr=b105e00d, pidr=4000bb00b, class=14>
pyocd-gdbserver: INFO:root:[1]<f0002000: cidr=b105900d, pidr=4000bb9a3, class=9, devtype=13, devid=0>
pyocd-gdbserver: INFO:root:CPU core is Cortex-M0
pyocd-gdbserver: INFO:root:4 hardware breakpoints, 0 literal comparators
pyocd-gdbserver: INFO:root:2 hardware watchpoints
pyocd-gdbserver: INFO:root:Telnet: server started on port 4444
pyocd-gdbserver: INFO:root:GDB server started at port:3333
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
pyocd-gdbserver: INFO:root:One client connected!
0x0001cf3e in ?? ()
1: (775) <-1011-interpreter-exec console "info sharedlibrary"
1: (775) ->~"No shared libraries loaded at this time.\n"
1: (775) ->1011^done
1: (776) ->(gdb)
1: (776) 1011: elapsed time 1
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
1: (786) <-1012-thread-info
1: (809) ->1012^done,threads=[{id="1",target-id="Thread 1",details="Thread mode",frame={level="0",addr="0x0001cf3e",func="??",args=[]},state="stopped",core="0"}],current-thread-id="1"
1: (809) ->(gdb)
1: (809) 1012: elapsed time 23
1: (819) <-1013-stack-list-frames 0 1000
1: (839) ->1013^done,stack=[frame={level="0",addr="0x0001cf3e",func="??"},frame={level="1",addr="0x0001ccf6",func="??"}]
1: (840) ->(gdb)
1: (840) 1013: elapsed time 21
C threads: null
1: (848) <--exec-continue
1: (849) ->~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
1: (857) ->^running
1: (857) ->*running,thread-id="all"
1: (857) ->(gdb)
1: (858) ->(gdb)

_had the same error with openOCD, so if somebody is looking for a solution maybe this will help:_
I started openOCD in terminal and realized that it doesn't print

GDB server started

but the final line is

adapter speed: 4000 kHz

So i changed the text of serverStarted and now it works. So try to run openOCD from your terminal and put the last text it prints when it successfully starts and put it into the variable serverStarted.

My launch.json now

Was this page helpful?
0 / 5 - 0 ratings