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

Unable to start debugger when watch expressions are configured #1582

Closed
3 tasks done
per1234 opened this issue Oct 27, 2022 · 3 comments · Fixed by #1706
Closed
3 tasks done

Unable to start debugger when watch expressions are configured #1582

per1234 opened this issue Oct 27, 2022 · 3 comments · Fixed by #1706
Assignees
Labels
conclusion: resolved Issue was resolved topic: debugger Related to the integrated debugger type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Oct 27, 2022

Describe the problem

Arduino IDE has an integrated debugger for debugging sketches.

One of the features of the debugger is the ability to configure expressions to "watch", which is useful for tracking the value of variables at each point in the program execution.

🐛 If a watch expression is configured, the debugger fails to start.

To reproduce

Equipment

Any board of a platform that is configured for use with the debugger (currently only "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" platform AFAIK).

A CMSIS-DAP compliant or J-Link debug probe. Note that the Arduino Zero has an on-board debug probe.

Steps

  1. Set up your board as needed for use with the debugger.
  2. Create and save a sketch that contains a variable you can watch:
    int foo;
    void setup() {}
    void loop() {
      foo++;
    }
  3. If you are using a J-Link, add the debug_custom.json file to the sketch:
    https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup#debugging-in-arduino-ide-20
  4. Enable Sketch > Optimize for Debugging in the Arduino IDE menus.
  5. Select Sketch > Upload from the Arduino IDE menus.
  6. Wait for the upload to finish.
  7. Click the "Start Debugging" button in the IDE toolbar.
  8. Wait for the debugger to start.
  9. Click the control next to "WATCH" in the "DEBUG" view to expand the "WATCH" section if it is not already expanded.
  10. Click the "+" icon ("Add Expression") button in the "WATCH" section heading.
  11. In the "Edit Watch Expression" field, type foo
  12. Click the OK button.
    🙂 The foo variable is watched as expected.
  13. Click the red square icon ("Stop") on the debugger toolbar.
  14. Click the green triangle icon ("Start Debugging") on the debugger toolbar.

🐛 The debugger does not start. An error notification is shown:

Request 4 cancelled on connection close

It will no longer be possible to start the debugger for that sketch even after restarting the IDE.

The debugger can only be started once more after removing the watch expression.

Expected behavior

Debugger can be started even if a watch expression is configured.

Arduino IDE version

2.0.1-snapshot-2b2463b

Operating system

  • Windows
  • Linux

Operating system version

  • Windows 10
  • Ubuntu 20.04

Additional context

The bug can be worked around by the following procedure:

  1. Hover the mouse pointer over the heading of the "WATCH" section in the debugger view. You will now see an icon with an X at the right side of the heading:
    image
    Click that icon.
  2. Start the debugger.
  3. Replace any watch expressions you need.

I bisected the introduction of the bug to 112153f / #791


I see the following log output after attempting to start the debugger under these conditions:

root INFO [hosted-plugin: 14416] Creating local connection: 722ebbc7-f483-4d36-bd66-67c1f636e6ec
root INFO [hosted-plugin: 14416] starting debug adapter session '722ebbc7-f483-4d36-bd66-67c1f636e6ec'
root INFO [hosted-plugin: 14416] Creating plugin connection: 722ebbc7-f483-4d36-bd66-67c1f636e6ec
root ERROR [hosted-plugin: 14416] (node:10684) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Arduino IDE --trace-deprecation ...` to show where the warning was created)
root ERROR [hosted-plugin: 14416] C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9
const s=r(3),n=r(1),o=r(12),i=r(51),a=process.binding("constants"),u=i(),c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", [... and tens of thousands more characters; longer than GitHub will allow in an issue]
root ERROR [hosted-plugin: 14416] n"[object Number]"===n.call(e)&&e%1==0},o.int=o.integer,o.notANumber=function(e){return!o.num(e)||e!=e},  [... and tens of thousands more characters; longer than GitHub will allow in an issue]


TypeError: Cannot read properties of undefined (reading 'showDevDebugOutput')
    at _.wrapTimeStamp (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:21659)
    at _.handleMsg (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:22029)
    at _.<anonymous> (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:39946)
    at Generator.next (<anonymous>)
    at C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:4272
    at new Promise (<anonymous>)
    at s (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:4017)
    at _.evaluateRequest (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:39565)
    at _.dispatchRequest (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:1:12109)
    at _.handleMessage (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:42356)
root INFO [hosted-plugin: 14416] onDebugAdapterExit session: '722ebbc7-f483-4d36-bd66-67c1f636e6ec'
root ERROR Error on disconnect
root ERROR [hosted-plugin: 14416] Error: ENOENT: no such file or directory, open 'c:\Users\per\Documents\Arduino\sketch_oct26b\.vscode\.cortex-debug.registers.state.json'
    at Object.openSync (node:fs:582:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:5:1800)
    at Object.writeFileSync (node:fs:2143:35)
    at t.RegisterTreeProvider._saveState (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\extension.js:214:12938)
    at t.RegisterTreeProvider.debugSessionTerminated (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\extension.js:214:13208)
    at k.debugSessionTerminated (C:\ide 2\tip\149-2b2463b\resources\app\plugins\cortex-debug\extension\dist\extension.js:129:61849)
    at C:\ide 2\tip\149-2b2463b\resources\app\node_modules\@theia\core\lib\common\event.js:103:69
    at CallbackList.invoke (C:\ide 2\tip\149-2b2463b\resources\app\node_modules\@theia\core\lib\common\event.js:109:26)
    at Emitter.fire (C:\ide 2\tip\149-2b2463b\resources\app\node_modules\@theia\core\lib\common\event.js:224:29)
    at DebugExtImpl.$sessionDidDestroy (C:\ide 2\tip\149-2b2463b\resources\app\node_modules\@theia\plugin-ext\lib\plugin\node\debug\debug.js:186:52) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'c:\\Users\\per\\Documents\\Arduino\\sketch_oct26b\\.vscode\\.cortex-debug.registers.state.json'
}

The problem still occurs, except without the ENOENT error in the logs, after I create c:\Users\per\Documents\Arduino\sketch_oct26b\.vscode\.cortex-debug.registers.state.json, which makes me question whether that part of the output is relevant.

Prior to 112153f, there was similar output:

root INFO [hosted-plugin: 14104] PLUGIN_HOST(14104): PluginManagerExtImpl/loadPlugin(E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\extension)
root INFO [hosted-plugin: 14104] Debug configuration provider has been registered: cortex-debug, trigger: 1
root ERROR [hosted-plugin: 14104] (node:10576) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
root ERROR [hosted-plugin: 14104] (node:10576) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'showDevDebugOutput' of undefined
    at _.wrapTimeStamp (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:21659)
    at _.handleMsg (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:22029)
    at _.<anonymous> (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:39946)
    at Generator.next (<anonymous>)
    at E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:4272
    at new Promise (<anonymous>)
    at s (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:4017)
    at _.evaluateRequest (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:39565)
    at _.dispatchRequest (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:1:12109)
    at _.handleMessage (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:42356)
root ERROR [hosted-plugin: 14104] (node:10576) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10576) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It may be related to #412 in that this is a report of the watch expression not working if it was configured before the debugger was started.


Originally reported at:

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: debugger Related to the integrated debugger labels Oct 27, 2022
@kittaakos kittaakos self-assigned this Oct 27, 2022
@kittaakos
Copy link
Contributor

@kittaakos
Copy link
Contributor

he problem still occurs, except without the ENOENT error in the logs, after I create c:\Users\per\Documents\Arduino\sketch_oct26b\.vscode\.cortex-debug.registers.state.json, which makes me question whether that part of the output is relevant.

Prior to 112153f, there was similar output:

root INFO [hosted-plugin: 14104] PLUGIN_HOST(14104): PluginManagerExtImpl/loadPlugin(E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\extension)
root INFO [hosted-plugin: 14104] Debug configuration provider has been registered: cortex-debug, trigger: 1
root ERROR [hosted-plugin: 14104] (node:10576) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
root ERROR [hosted-plugin: 14104] (node:10576) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'showDevDebugOutput' of undefined
    at _.wrapTimeStamp (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:21659)
    at _.handleMsg (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:22029)
    at _.<anonymous> (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:39946)
    at Generator.next (<anonymous>)
    at E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:4272
    at new Promise (<anonymous>)
    at s (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:4017)
    at _.evaluateRequest (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:39565)
    at _.dispatchRequest (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:1:12109)
    at _.handleMessage (E:\ide2\tip\1-69ac1f4\resources\app\plugins\cortex-debug\extension\dist\debugadapter.js:9:42356)
root ERROR [hosted-plugin: 14104] (node:10576) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10576) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I remember having this error from day one. I downloaded beta-1, and here is the same error. It never worked.

Version: 2.0.0-beta.1
Date: 2021-02-12T12:10:18.013Z
CLI Version: nightly-20210212 alpha [560025a6]
root ERROR [hosted-plugin: 75334] Error: ENOENT: no such file or directory, open '/Users/a.kitta/Documents/Arduino/debug/.vscode/.cortex-debug.registers.state.json'
    at Object.openSync (fs.js:440:3)
    at Object.func [as openSync] (electron/js2c/asar.js:140:31)
    at Object.writeFileSync (fs.js:1265:35)
    at t.RegisterTreeProvider._saveState (/Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/plugins/cortex-debug/extension/dist/extension.js:212:12839)
    at t.RegisterTreeProvider.debugSessionTerminated (/Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/plugins/cortex-debug/extension/dist/extension.js:212:13109)
    at k.debugSessionTerminated (/Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/plugins/cortex-debug/extension/dist/extension.js:127:49212)
    at /Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/node_modules/@theia/core/lib/common/event.js:176:33
    at CallbackList.invoke (/Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/node_modules/@theia/core/lib/common/event.js:191:39)
    at Emitter.fire (/Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/node_modules/@theia/core/lib/common/event.js:318:29)
    at DebugExtImpl.<anonymous> (/Users/a.kitta/Desktop/ide beta-1/Arduino IDE.app/Contents/Resources/app/node_modules/@theia/plugin-ext/lib/plugin/node/debug/debug.js:315:60) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/a.kitta/Documents/Arduino/debug/.vscode/.cortex-debug.registers.state.json'
}

@DeqingSun
Copy link

@per1234
Thank your for mentioning the bug in the debug issue. Yes I found the one sketch that has the error and there was a watch item.

Once removed, the error disaapears. Once added back, error appears again.

kittaakos pushed a commit to kittaakos/arduino-ide that referenced this issue Nov 24, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: debugger Related to the integrated debugger type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants