microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Unjustified "Trace/breakpoint trap" with GDB server #1298

Open politoleo opened 6 years ago

politoleo commented 6 years ago

First of all thank you for all this work, it's great. I'm using vscode+cpptools+IAR extension to deveolp embedded device software. Everything is working fine (with the already known limitation), but there's an issue that I'm not able to identify. The issue is present always, and could be reproduced in the following ways:

-Each time I launch the server, and no breakpoint are set before the main (that is not the real entry point), I get a Trace/breakpoint trap and the program stop at it. stopAtEntry settings makes no difference.

-Each time I press pause the program correctly stop at the point where it's running, however it generates again Trace/breakpoint trap, even if it knows that it was me requiring the program to pause.

-Each time I set a breakpoint while the program is running, and the breakpoint is far enough from PC, I get a Trace/breakpoint trap in the exact same way as I I had pressed pause.

Since this behaviour is the same on Visual Studio 2017 my first guess is that it has to do to some IPC being out of sync and looked at the common denominator: the MIEngine. I tried then to debug the MIEngine as described in cpptools documentation folder, but cpptools failed to start with the my newly produced binary (sign required?).

The debugger and GDB server I'm using is JLink, and vscode and vscode-cpptools are updated.

This is the launch.json configuration file, I think that it would be easy to reproduce by just using a different binary and a jlink.

{
  "version": "0.2.1",
  "configurations": [
    {
      "name": "Debug J-Link",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceRoot}/project/build/debug/project.out",
      "stopAtEntry": true,
      "cwd": "${workspaceRoot}",
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "arm-none-eabi-gdb.exe",
      "debugServerPath": "JLinkGDBServerCL.exe",
      "debugServerArgs": "-if swd -singlerun -strict -endian little -speed auto -port 3333 -device STM32F303VE -vd -halt",
      "serverStarted": "Connected\\ to\\ target",
      "targetArchitecture": "arm",
      "serverLaunchTimeout": 5000,
      "filterStderr": false,
      "filterStdout": true,
      "logging": {
        "trace": false,
        "traceResponse": false,
        "engineLogging": true
      },
      "setupCommands": [
        {"text": "target remote localhost:3333"},
        {"text": "monitor flash breakpoints = 1"},
        {"text": "monitor flash download = 1"},
        {"text": "monitor reset"},
        {"text": "load project.out"},
        {"text": "monitor reset"}
      ]
    }
  ]
}

Below the screen of the error, and a trace log when I press pause:

pause_trace.txt

pause

main

pieandcakes commented 6 years ago

@politoleo We need to stop at entry regardless whether or not stopAtEntry is set. This is so that we can setup the debugging session with commands that can only be run if the debugger is connected. The stopAtEntry setting tells it whether or not to autocontinue or to wait and display the stopping event to the user.

The Trace/Breakpoint trap message is from the debugger we are communicating with. It sounds like JLink gives that message everytime it stops and we capture that as a stopping event.

@paulmaybee @robotdad Is that trace/breakpoint trap message something that can be suppressed?

widavies commented 1 year ago

Isn't is stopOnEntry not stopAtEntry?