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

feat: handle when starting debug session failed #1809

Merged
merged 2 commits into from
Jan 23, 2023
Merged

feat: handle when starting debug session failed #1809

merged 2 commits into from
Jan 23, 2023

Conversation

kittaakos
Copy link
Contributor

@kittaakos kittaakos commented Jan 9, 2023

Motivation

IDE2 should clearly communicate to the user when starting a debug session has failed due to an unverified sketch. In this case, users have to verify the sketch and restart the debug session.

Change description

This PR consists of two changes:

808.mp4

Steps to verify:

  • attach your Arduino Zero board to the programming port,
  • create a new sketch,
  • click on the debug in the toolbar,
  • expect the error message,
  • click on the yes action to verify the sketch,
  • click on the debug icon in the toolbar,
  • debugger starts.

Other information

Reviewer checklist

Closes #808

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@kittaakos kittaakos added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: debugger Related to the integrated debugger labels Jan 9, 2023
@kittaakos kittaakos requested review from per1234 and AlbyIanna January 9, 2023 14:16
Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, code is 👌

@kittaakos kittaakos added the status: on hold Do not proceed at this time label Jan 11, 2023
@kittaakos
Copy link
Contributor Author

kittaakos commented Jan 11, 2023

It's on hold. This PR is blocked by arduino/vscode-arduino-tools#39 Done ✅

@kittaakos kittaakos removed the status: on hold Do not proceed at this time label Jan 11, 2023
Comment on lines 671 to 678
async tempBuildPath(sketch: Sketch): Promise<string> {
const sketchPath = FileUri.fsPath(sketch.uri);
const hash = crypto
.createHash('md5')
.update(sketchPath)
.digest('hex')
.toUpperCase();
return join(this.isTempSketch.tempDirRealpath, `arduino-sketch-${hash}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I follow the reproduction instructions from #808 (comment) on my Windows machine, I get the raw error from Arduino CLI in the notification:

Error getting Debug info: Compiled sketch not found in C:\Users\per\AppData\Local\Temp\arduino-sketch-AEA9FCC61D66FCE9E9A157F96547FFB0

Instead of the expected user friendly interpretation from Arduino IDE:

Sketch 'sketch_jan16b' must be verified before starting a debug session. Please verify the sketch and start debugging again. Do you want to verify the sketch now?

I set a breakpoint here:

return err.message.includes(tempBuildPath);

I see that the value of tempBuildPath is:

c:\\Users\\per\\AppData\\Local\\Temp\\arduino-sketch-956C36A70086EB62B81F7E1AA8AEE643

In addition to the difference in hash, I notice the different case of the drive letters (c vs C).


I get the expected user friendly notification text on my Linux machine.

Copy link
Contributor Author

@kittaakos kittaakos Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I patched the PR. It's a complete hack, but finally, it works on Windows too:

808_win.mp4

macOS:

808_macos.mp4

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works perfectly now on Windows too.

Thanks Akos!

.update(path)
.digest('hex')
.toUpperCase();
const folderName = `arduino-sketch-${hash}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct for the version of Arduino CLI currently used by Arduino IDE, but it will break when the Arduino CLI dependency is bumped:

After those changes, the path is now <temp dir>/arduino/sketches/<hash>.

No action needed now, but I thought to add a note in anticipation of the adjustment that will be needed at the time of the Arduino CLI dependency bump.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the heads-up!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a test for the build path: fd38ba4.

I had to change the IDE2 logic when stopping and restarting the daemon. I have to double-check it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to double-check it.

The ready deferred promise is not used anywhere else; the change must not break anything. We need to clean up this code next time we change the core gRPC clients.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have decided to drop everything I changed after the review and moved it to a separate PR: #1823. If the build is green, I would like to merge it as it is if you are OK with it, Per. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm OK with that. Feel free to merge anytime you are ready Akos.

Akos Kitta added 2 commits January 19, 2023 16:03
If the sketch has not been verified, IDE2 offers user a verify action.

Closes #808

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
IDE2 does not know what casing the CLI uses

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: debugger Related to the integrated debugger type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Communicate to the user cause of debugger not starting with uncompiled sketch
3 participants