Vscode-cpptools: Cannot pause debugger on Linux

Created on 8 Jun 2017  路  32Comments  路  Source: microsoft/vscode-cpptools

  • VSCode Version: Code - Insiders 1.14.0-insider (42ede266aa9ce62e258d54e73576642ab684eb43, 2017-06-06T05:11:05.627Z)
  • OS Version: Linux x64 4.8.0-53-generic
  • Extensions:

|Extension|Author|Version|
|---|---|---|
|code-gnu-global|austin|0.2.2|
|gitlens|eamodio|3.6.1|
|cpptools|ms-vscode|0.11.4|;


Steps to Reproduce:

1.
2.

Log from DEBUG CONSOLE:

C pause: {"threadId":57005}
 R: {"success":true,"message":null,"request_seq":12,"command":"pause","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

Clone of https://github.com/Microsoft/vscode/issues/28246. Wasn't sure which repo was appropriate for this ticket.

debugger embedded

All 32 comments

Can you set breakpoints? the log looks like it paused. Does the UI look like its still running?

It doesn't actually pause the CPU.
I can set only set breakpoints before the debugger starts or when its already halted at another breakpoint.

This is the log when trying to set a breakpoint when the cpu isn't halted:

C setBreakpoints: {"source":{"path":"/home/arosenthal/Documents/code/path/to/file.c","name":"file.c"},"lines":[47],"breakpoints":[{"line":47}],"sourceModified":false}
 R: {"success":true,"message":null,"request_seq":19,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"verified":true,"line":47,"message":null}]},"running":false,"refs":null,"seq":0,"type":"response"}
E breakpoint: {"reason":"changed","breakpoint":{"id":1,"verified":false,"line":47,"message":"Attempting to bind the breakpoint...."},"type":"breakpoint"}
1: (42477) ->~"\nProgram received signal "
1: (42478) ->~"SIGTRAP, Trace/breakpoint trap.\n"
E output: {"category":"stdout","output":"\nProgram received signal ","data":null,"type":"output"}

@AlanRosenthal was this working before?

It was working on Windows, not on Linux.

Which version of Linux is this? it says Linux x64 generic. I have Ubuntu but I can't repro this.

This is the log when trying (and succeeding) to set a breakpoint when the cpu IS halted:

C setBreakpoints: {"source":{"path":"/home/arosenthal/path/to/file.c","name":"file.c"},"lines":[445],"breakpoints":[{"line":445}],"sourceModified":false}
1: (34465) <-1020-break-insert -f file.c:445
1: (34469) ->1020^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x600168b8",func="Function",file="../../../path/to/file.c",fullname="/home/arosenthal/path/to/file.c",line="445",thread-groups=["i1"],times="0",original-location="file.c:445"}
1: (34469) ->(gdb)
1: (34470) 1020: elapsed time 5
 R: {"success":true,"message":null,"request_seq":20,"command":"setBreakpoints","body":{"breakpoints":[{"id":2,"verified":true,"line":445,"message":null}]},"running":false,"refs":null,"seq":0,"type":"response"}
E breakpoint: {"reason":"changed","breakpoint":{"id":2,"verified":true,"line":445,"message":null},"type":"breakpoint"}
arosenthal@alan-lenovo-ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial
arosenthal@alan-lenovo-ubuntu:~$ arm-none-eabi-gdb-py --version
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20151217-cvs
Copyright (C) 2015 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=i686-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".

I'll have to see if I can find an arm Linux device here so I can test this.

@AlanRosenthal thanks

@pieandcakes I have same situation, I cannot pause debugger or set breakpoints while it's running.

Same log I got when I tried to pause:

C pause: {"threadId":-2}
 R: {"success":true,"message":null,"request_seq":11,"command":"pause","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

VS Code Version 1.17.0
OS version:

      System Version: macOS 10.12.6 (16G29)
      Kernel Version: Darwin 16.7.0

I tried to use following versions of arm gdb:

GNU gdb (GNU Tools for ARM Embedded Processors 6-2017-q1-update) 7.12.1.20170215-git
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".

and

GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160923-cvs
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "arm",
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/local/bin/arm-none-eabi-gdb",
            "debugServerPath": "/usr/local/bin/openocd",
            "debugServerArgs": "-f ${workspaceRoot}/oocd_stlink.cfg",
            "program":"${workspaceRoot}/build/mcuboard.elf",
            "setupCommands": [
                { "text": "target remote localhost:3333" },
                { "text": "file ${workspaceRoot}/build/mcuboard.elf" },
                { "text": "monitor reset init" },
                { "text": "mon reg"},
                { "text": "info frame"}
            ],
            "stopAtEntry": true,
            "serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
            "cwd": "${workspaceRoot}",
            "filterStderr": true,
            "filterStdout": false,
            "logging": { "trace": true, "traceResponse": true, "engineLogging": true }
        }
    ]
}

@partyzzzan Can you enable "engineLogging": true in your logging block and let me know what you get back? It looks like we request to pause the debugger and the fact that you get a success message means gdb is telling us you have paused.

Setting breakpoints while running is a different issue than pausing.

@pieandcakes
Yes, it was already enabled (see my launch.json).

See, here I clicked "pause" 3 times and "stop" 1 time - nothing happened:

C continue: {"threadId":-2}
1: (39338) <--exec-continue
 R: {"success":true,"message":null,"request_seq":10,"command":"continue","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
1: (39338) ->^running
1: (39338) ->*running,thread-id="all"
1: (39338) ->(gdb)
1: (39338) ->(gdb)
E output: {"category":"stdout","output":"openocd: Info : halted: PC: 0x0801bba2\n","data":null,"type":"output"}
openocd: Info : halted: PC: 0x0801bba2
C pause: {"threadId":-2}
 R: {"success":true,"message":null,"request_seq":11,"command":"pause","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
C pause: {"threadId":-2}
 R: {"success":true,"message":null,"request_seq":12,"command":"pause","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
C pause: {"threadId":-2}
 R: {"success":true,"message":null,"request_seq":13,"command":"pause","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
C disconnect: {"restart":false}

This log I get if I click "stop" when code execution paused on "main" breakpoint:

C disconnect: {"restart":false}
1: (16842) <-1023kill
1: (16842) ->&"kill\n"
1: (16842) ->~"Kill the program being debugged? (y or n) [answered Y; input not from terminal]\n"
1: (16842) ->=thread-group-exited,id="i1"
1: (16842) ->1023^done
1: (16842) ->(gdb)
E output: {"category":"stdout","output":"openocd: Info : dropped 'gdb' connection\n","data":null,"type":"output"}
openocd: Info : dropped 'gdb' connection
E output: {"category":"stdout","output":"Kill the program being debugged? (y or n) [answered Y; input not from terminal]\n","data":null,"type":"output"}
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
1: (16844) 1023: elapsed time 2
1: (16844) <--gdb-exit
1: (16844) ->^exit
1: (16846) "/usr/local/bin/arm-none-eabi-gdb" exited with code 0 (0x0).
1: (16846) <-logout
1: (16848) <-logout
E output: {"category":"console","output":"The program '/Users/antonzaytsev/Projects/mcuboard/build/mcuboard.elf' has exited with code 0 (0x00000000).\r\n\n","data":null,"type":"output"}
The program '/Users/antonzaytsev/Projects/mcuboard/build/mcuboard.elf' has exited with code 0 (0x00000000).
E exited: {"exitCode":0,"type":"exited"}
E terminated: {"type":"terminated"}
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.40908.1","VS.Diagnostics.Debugger.HostVersion":"1.0.30908.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":1},"type":"output"}
 R: {"success":true,"message":null,"request_seq":10,"command":"disconnect","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

@partyzzzan I'm looking for an actual pause command to be sent to gdb. I don't see it (should start with <--).

@robotdad @paulmaybee Do either of you know why this would be an issue? I don't have enough experience with arm gdb or openocd to know if this is a known issue or if there is a tweak necessary to make it work.

@pieandcakes

I'm looking for an actual pause command to be sent to gdb. I don't see it (should start with <--).

Yes, that is what I am writing about.

Same situation with "stop" and "setBreakpoints" commands: they are working while code is paused, gdb log is there, everything looks good. But if i press continue - nothing works, no gdb log, no real actions, nothing.

That is why I post my logs of "stop" command in 2 cases: on pause and during code execution.

Did you guys solve this issue? I'm encountering it now, cannot pause debugger or set breakpoints while it's running. I'm using arm-none-eabi-gdb too and my logs are exactly the same as @partyzzzan.

@pieandcakes I'm hitting a bug where I can't pause in the debugger, but I can set/hit breakpoints (I sent an email about it last week).

@sean-mcmanus For your issue I responded to your email. It is a VS Code issue. https://github.com/Microsoft/vscode/issues/62085 . @TonyHoang94 If you are using VS Code 1.28.2 it might be the same issue.

I'm developing my own Debug Adapter and I've run into the same issue - clicking Pause after running the debugger does nothing - it never reaches pauseRequest call. I also found out that tweaking some of my configuration (the one set with initializeRequest) would suddenly make the pause trigger. The problem remains though because UI is not adjusted to the state I'd expect it to have - once I pause it will not allow to resume. I have similar issue with breakpoint being hit (I send "stopped(breakpoint)" event, but it will never change back the UI and it keeps showing "Continue". I tried it on recent VS Code and also on Insiders (1.29.0).

Setting breakpoints works. It seems like VS gets into some undefined state where UI is not adjusted correctly to what I'd expect from the events that I call...

@noizex Yea, I filed an issue with VS Code to investigate as this isn't our extension's issue.

Did you guys solve this issue? My logs are nearly the same as @partyzzzan with vsc Version 1.33.1
<-- C (pause-14): {"command":"pause","arguments":{"threadId":57005},"type":"request","seq":14} --> R (pause-14): {"request_seq":14,"success":true,"command":"pause","body":{},"seq":3895,"type":"response"}
Feel free to ask any questions.

Sorry @kiwi616, I haven't worked on it since encountering the issue - decided to give it some time, as maybe it was some intermittent issue that will get fixed. I see it's still a problem there? I will try to come back to my debugger and see if I still have the same problem.

Hi, has anyone sorted it out?

Is there any progress on this issue? I'm working with openocd (0.10.0) and GNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) and I'm having the same problem with vscode 1.43.2.

@WardenGnaw Please review.

I'm seeing this on VSCode 1.49.1 using cppdbg if you start without any breakpoints and have stopAtEntry set to false.

I am able to see the CALL STACK, click on a thread, then pause via that means, or hot add a breakpoint, but it is strange behavior to not have the main pause button available.

I am having the same issue when debugging a remote embedded target. Every time I run gdb in a terminal, everything works fine, that is I can ctrl+c interrupt any time and read the registers, memory etc.. When debugging in vscode, pause button does nothing, there is no way to interrupt execution, though breakpoints work fine.

Am I doing anything wrong? Please let me know if you would like more info. This is a very crucial issue for me.

Edit: I tried with different debugger probes (jlink and stlink each has its own gdb server) and the issue persists. I think it has to do with vscode communicating to arm-none-eabi-gdb (aka arm embedded debugger).

vscode version

Version: 1.50.1
Commit: d2e414d9e4239a252d1ab117bd7067f125afd80a
Date: 2020-10-13T14:53:05.704Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

launch file

"version": "0.2.0",
    "configurations": [
        {
            "name": "debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/build/Debug/bin/windrider.elf",
            "miDebuggerPath": "/Applications/ARM/bin/arm-none-eabi-gdb",
            "cwd": "${workspaceRoot}",
            "MIMode": "gdb",
            "externalConsole": true,
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Connect to gdb server",
                    "text": "target remote localhost:61234"
                },
                {
                    "description": "load executable",
                    "text": "file ${workspaceRoot}/build/Debug/bin/windrider.elf"
                },
                {
                    "description": "Flash Firmware, Reset and Halt Target",
                    "text": "load"
                },
            ]
        }
    ]

Add to launch.json file debugServerPath and debugServerArgs parameters in order to run gdb server with the plugin. I had the same issue before that.

My launch.json file

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug app",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            // "miDebuggerServerAddress": "localhost:2331",
            "debugServerPath": "JLinkGDBServer",
            "debugServerArgs": "-device STM32F042K6 -halt",
            "logging": { "engineLogging": false, "trace": false, "traceResponse": false },
            "preLaunchTask": "Deploy",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {"text": "target remote localhost:2331" },
                {"text": "tbreak main"},
                {"text": "monitor halt"},
                {"text": "monitor reset"},           
            ],
        }
    ]
}

It was tested with arm-none-eabi-gdb debugger as well.

@lukas9409 Amazing! Thank you, it works! What's wrong with running the gdb server in a separate terminal?

Frankly speaking I don't know. That's really good question for the plugin development team. I suppose that plugin need to know it is remote session. If you set miDebuggerServerAddress (you can delete debugServerPath and debugServerArgs) it still works. However this solution is not enough for me, due to _setupCommands_ are called before remote connection (the _monitor_ commands only works with remotes).

To sum up, it isn't the correct solution, but rather workaround of issue. If you run a gdbserver on remote machine (connection via network) it fails.

BTW: Adding _setupCommands_ to connected remote (after _target remote_ command) would be a nice feature!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DemoCrazer picture DemoCrazer  路  3Comments

jheinzel picture jheinzel  路  3Comments

wdc596933938 picture wdc596933938  路  3Comments

ecbrodie picture ecbrodie  路  3Comments

montery8 picture montery8  路  3Comments