Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pause debugger on Linux #807

Open
AlanRosenthal opened this issue Jun 8, 2017 · 37 comments
Open

Cannot pause debugger on Linux #807

AlanRosenthal opened this issue Jun 8, 2017 · 37 comments
Assignees

Comments

@AlanRosenthal
Copy link

  • 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:

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 microsoft/vscode#28246. Wasn't sure which repo was appropriate for this ticket.

@pieandcakes
Copy link
Contributor

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

@pieandcakes pieandcakes self-assigned this Jun 8, 2017
@AlanRosenthal
Copy link
Author

AlanRosenthal commented Jun 8, 2017

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"}

@pieandcakes
Copy link
Contributor

pieandcakes commented Jun 8, 2017

@AlanRosenthal was this working before?

@AlanRosenthal
Copy link
Author

It was working on Windows, not on Linux.

@pieandcakes
Copy link
Contributor

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

@AlanRosenthal
Copy link
Author

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"}

@AlanRosenthal
Copy link
Author

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

@AlanRosenthal
Copy link
Author

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".

@pieandcakes
Copy link
Contributor

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

@AlanRosenthal
Copy link
Author

in case you need my launch.json: #792 (comment)

@pieandcakes
Copy link
Contributor

@AlanRosenthal thanks

@partyzzzan
Copy link

partyzzzan commented Oct 11, 2017

@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 }
        }
    ]
}

@pieandcakes
Copy link
Contributor

@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.

@partyzzzan
Copy link

partyzzzan commented Oct 13, 2017

@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}

@partyzzzan
Copy link

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"}

@pieandcakes
Copy link
Contributor

@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.

@partyzzzan
Copy link

partyzzzan commented Oct 13, 2017

@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.

@TonyHoang94
Copy link

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.

@sean-mcmanus
Copy link
Contributor

@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).

@pieandcakes
Copy link
Contributor

@sean-mcmanus For your issue I responded to your email. It is a VS Code issue. microsoft/vscode#62085 . @TonyHoang94 If you are using VS Code 1.28.2 it might be the same issue.

@noizex
Copy link

noizex commented Oct 29, 2018

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...

@pieandcakes
Copy link
Contributor

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

@kiwi616
Copy link

kiwi616 commented Apr 23, 2019

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.

@noizex
Copy link

noizex commented Apr 23, 2019

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.

@duddie
Copy link

duddie commented Oct 29, 2019

Hi, has anyone sorted it out?

@mguc
Copy link

mguc commented Apr 7, 2020

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.

@pieandcakes
Copy link
Contributor

@WardenGnaw Please review.

@eurijk
Copy link

eurijk commented Sep 23, 2020

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.

@stansotn
Copy link

stansotn commented Oct 22, 2020

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"
                },
            ]
        }
    ]

@lkrzysciak
Copy link

lkrzysciak commented Oct 22, 2020

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.

@stansotn
Copy link

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

@lkrzysciak
Copy link

lkrzysciak commented Oct 23, 2020

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!

@biboc
Copy link

biboc commented Mar 26, 2021

I made it work by using Cortex-Debug 0.3.12 extension.
The extension launch gdb server as well, it is the same as @lukas9409 mentioned earlier

Here is my launch.json if it can help:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "launch",
            "name": "Debug (OpenOCD)",
            "servertype": "openocd",
            "cwd": "${workspaceRoot}",
            "runToMain": true,
            "executable": "bin/hello-world.elf",
            "device": "DEVICE_NAME",
            "configFiles": [
                "dist/openocd.cfg"
            ],
            "swoConfig": {
                "enabled": true,
                "cpuFrequency": 8000000,
                "swoFrequency": 2000000,
                "source": "probe",
                "decoders": [
                    { "type": "console", "label": "ITM", "port": 0 }
                ]
            }
        }
    ]
}

Play/Pause works

@stansotn
Copy link

Cortex-Debug works for me too, but it's very specific with the devices it supports. The point here is that the native vscode cpptools extension should be agnostic to the flavor of the remote gdb server.

@lygstate
Copy link
Contributor

Also faced this annoy bug on win32/mingw
It's seems the cppdbg didn't implement pause instruction properly.

@ThoSe1990
Copy link

ThoSe1990 commented Jul 7, 2021

same here, cant pause program during execution nor adding breakpoints.

breakppoints which are added before program execution are recognized, then when a already added breakpoint is reached, it is possible to add other brekapoints, but once i run the programm it isnt possible to add breakpoints anymore.

when i just try to pause the running porgramm, i need to kill the task because stopping via the stop button doesnt work as well then....

ms-vscode.cpptools v1.4.1

Edit: probelm occured on windows.

@seppeon
Copy link

seppeon commented Dec 14, 2021

Yeah, same here, with mingw.

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

No branches or pull requests