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

🐛 Support displaying variables with non-unicode data #758

Merged
merged 3 commits into from
Oct 25, 2022
Merged

🐛 Support displaying variables with non-unicode data #758

merged 3 commits into from
Oct 25, 2022

Conversation

marianosimone
Copy link
Contributor

@marianosimone marianosimone commented Sep 21, 2022

Description

This fixes #756

DAP is JSON-based, so the state of all variables is dumped into a string that needs to be unicode. When a variable contains binary data that is NOT unicode, this breaks with: source sequence is illegal/malformed utf-8.

This patch makes sure that we can display at least part, and show the user that the data they are seeing is not exactly the one that is in memory.

Testing

I tried this in VSCode (which uses DAP), and saw:

  1. Before this patch: the debugging session crashes
  2. After this patch:

image

As a side note, vscode-ruby-debug doesn't even try to show the variable content and just shows [Invalid encoding], which, IMO, is a worse UX.

},
{
name: "with_binary_data",
value: "[Invalid encoding] \b�\u0001",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the interesting part! Without the fix, this would have crashed instead

@ko1 ko1 added the bug Something isn't working label Oct 4, 2022
@ko1 ko1 added this to the v1.7.0 milestone Oct 4, 2022
@ko1
Copy link
Collaborator

ko1 commented Oct 4, 2022

Let me check another debuggers on VSCode (DAP servers)

lib/debug/server_dap.rb Outdated Show resolved Hide resolved
marianosimone and others added 2 commits October 24, 2022 15:12
Co-authored-by: Koichi Sasada <ko1@atdot.net>
@ko1 ko1 merged commit 4d914d8 into ruby:master Oct 25, 2022
@ko1
Copy link
Collaborator

ko1 commented Oct 25, 2022

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

DAP Server fails when dealing with some binary data
2 participants