Skip to content

Debugger restart error if debug icon is pressed after a stop #46

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

Closed
rsora opened this issue Feb 26, 2021 · 2 comments · Fixed by #50
Closed

Debugger restart error if debug icon is pressed after a stop #46

rsora opened this issue Feb 26, 2021 · 2 comments · Fixed by #50
Assignees
Labels
conclusion: resolved Issue was resolved criticality: medium Of moderate impact topic: code Related to content of the project itself topic: debugger Related to the integrated debugger type: imperfection Perceived defect in any part of project

Comments

@rsora
Copy link
Contributor

rsora commented Feb 26, 2021

Describe the bug
Some times the debug button behavior triggers a failed launch of openocd probably due to a bug in the GUI code

To Reproduce
Steps to reproduce the behavior:

  1. Open a sketch
  2. Connect a debug enabled board (like an Arduino Zero)
  3. Select Sketch > Optimize for Debugging
  4. Upload Sketch
  5. Click the Debug Button
    image
  6. Add a breakpoint in your sketch
  7. Click "Continue" in the Debugger control bar
    image
  8. Click "Stop" in the Debugger control bar
  9. Click the Debug button again and wait
  10. See the error (also reported in the screenshot below)
Failed to launch OpenOCD GDB Server: Error: spawn /home/rsora/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd ENOENT

Please note that the last 3 steps may need to be performed a few times before seeing the failure.
Reproducibility is not consistent

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: we were able to reporduce the issue on Linux and MacOS and Windows
  • Version: 2.0.0-beta.3-snapshot.9fb8c4b
  • Date: 2021-02-25T15:29:51.087Z
  • CLI Version: 0.16.1 alpha [76f55490]
@rsora rsora added type: bug priority: medium Resolution is a medium priority labels Feb 26, 2021
@kittaakos
Copy link
Contributor

It appears to be an issue with Theia. When starting the very first debug session from the toolbar right after the app startup, I can see the following debug configuration (note that cwd is correctly resolved from '{workspaceRoot} to my actual FS location). When starting the next session, it is not resolved.

Config after the first start:

{
  "id": 0,
  "configuration": {
    "cwd": "/Users/akos.kitta/Documents/Arduino/xxx",
    "name": "Arduino",
    "request": "launch",
    "type": "cortex-debug",
    "executable": "/var/folders/k3/d2fkvv1j16v3_rz93k7f74180000gn/T/arduino-sketch-062822A8FE3586E9C342920A463F4CF4/xxx.ino.elf",
    "servertype": "openocd",
    "serverpath": "/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd",
    "armToolchainPath": "/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/",
    "configFiles": [
      "/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/samd/1.8.11/variants/arduino_zero/openocd_scripts/arduino_zero.cfg"
    ],
    "debuggerArgs": [],
    "swoConfig": {
      "enabled": false,
      "decoders": [],
      "cpuFrequency": 0,
      "swoFrequency": 0,
      "source": "probe"
    },
    "graphConfig": [],
    "preLaunchCommands": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "searchDir": [],
    "toolchainPath": "/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/",
    "toolchainPrefix": "arm-none-eabi",
    "extensionPath": "/Users/akos.kitta/git/arduino-ide/plugins/cortex-debug/extension",
    "flattenAnonymous": false,
    "registerUseNaturalFormat": true
  }
}

Config after the second start:

{
  "id": 1,
  "configuration": {
    "cwd": "${workspaceRoot}",
    "name": "Arduino",
    "request": "launch",
    "type": "cortex-debug",
    "executable": "/var/folders/k3/d2fkvv1j16v3_rz93k7f74180000gn/T/arduino-sketch-062822A8FE3586E9C342920A463F4CF4/xxx.ino.elf",
    "servertype": "openocd",
    "serverpath": "/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd",
    "armToolchainPath": "/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/",
    "configFiles": [
      "/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/samd/1.8.11/variants/arduino_zero/openocd_scripts/arduino_zero.cfg"
    ],
    "debuggerArgs": [],
    "swoConfig": {
      "enabled": false,
      "decoders": [],
      "cpuFrequency": 0,
      "swoFrequency": 0,
      "source": "probe"
    },
    "graphConfig": [],
    "preLaunchCommands": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "searchDir": [],
    "toolchainPath": "/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/",
    "toolchainPrefix": "arm-none-eabi",
    "extensionPath": "/Users/akos.kitta/git/arduino-ide/plugins/cortex-debug/extension",
    "flattenAnonymous": false,
    "registerUseNaturalFormat": true
  }
}

@kittaakos
Copy link
Contributor

Found it; it is crazy.

When one starts the debug session, the cortex-debug VSX will force to stop on entry. The debugger halts the debug session, and opens the editor of the directories.data/packages/arduino/hardware/samd/1.8.11/cores/arduino/cortex_handlers.c file. This cortex_handlers.c file is outside of the workspace, so when the user starts another debug session, this current editor (cortex_handlers.c) will be used as the anchor to calculate the workspace root, but it is outside of the workspace. So the cwd cannot be resolved against the ${workspaceRoot} variable. It will remain undefined and breaks the debug config.

Workaround for the time being:

  • Open the app,
  • Start the debug session from the toolbar,
  • Stop the debug session,
  • Select the sketch editor (so that it has the focus and will become the current widget),
  • Start the debug session from the toolbar (Now it works.)

This is the point where we need to customize the default Theia behavior: https://github.com/eclipse-theia/theia/blob/f8bcc19eba884cbd64112aeb691e8c97aad87197/packages/workspace/src/browser/workspace-variable-contribution.ts#L213.

Also, it would be great to configure cortex-debug not to stop on entry.

@kittaakos kittaakos self-assigned this Mar 1, 2021
kittaakos pushed a commit that referenced this issue Mar 1, 2021
Fall back to the current sketch, if `currentWidget` points to a file
outside of the workspace.

Closes: #46
Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit that referenced this issue Mar 1, 2021
Fall back to the current sketch, if `currentWidget` points to a file
outside of the workspace.

Closes: #46

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit that referenced this issue Mar 3, 2021
Fall back to the current sketch, if `currentWidget` points to a file
outside of the workspace.

Closes: #46

Signed-off-by: Akos Kitta <[email protected]>
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
@per1234 per1234 added conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: debugger Related to the integrated debugger labels Oct 29, 2021
@rsora rsora added criticality: medium Of moderate impact and removed priority: medium Resolution is a medium priority labels Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved criticality: medium Of moderate impact topic: code Related to content of the project itself topic: debugger Related to the integrated debugger type: imperfection Perceived defect in any part of project
Projects
None yet
3 participants