Git Product home page Git Product logo

Comments (14)

hediet avatar hediet commented on September 1, 2024

Can you try evaluating a string in the Debug Console and show me the result?

from vscode-debug-visualizer.

pakLebah avatar pakLebah commented on September 1, 2024

Here’s my code:

let s = "This is a string"
print(s)

I put a breakpoint on the first line. After the debugger passed the first line then I typed p s on the Debug Console. Here’s the result:

p s
(String) $R0 = "This is a string"
Module loaded: __lldb_dlopen_wrapper.
Module loaded: __lldb_caller_function.
Module loaded: /usr/lib/swift/libswiftSwiftOnoneSupport.dylib. Symbols loaded.

Is that you want?

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

Hmm, thats quite verbose. What do you see when watching that variable in the watch window?
Can you use a string with problemantic characters? (\n or ")

from vscode-debug-visualizer.

pakLebah avatar pakLebah commented on September 1, 2024

Hmm, thats quite verbose. What do you see when watching that variable in the watch window?

I saw This is a string, obviously.

Can you use a string with problemantic characters? (\n or “)

Of course. I can debug any kind of string combination, including emoji, on VS Code using CodeLLDB.

The problem is, your extension failed to show the value, not the debugger.

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

The problem is, your extension failed to show the value, not the debugger.

Thank you for clarifying that.

I saw This is a string, obviously.

You might reconsider what you think is obvious and you should sharpen your understanding of details.
If (String) $R0 = "This is a string" was the result of the evaluation, my extension could never guess the actual start of the string content due to the (String) $R0 = prefix.
Now you say the result in the watch window is This is a string (which is a different from (String) $R0 = "This is a string" - clearly, the Swift debug adapter formats the output of an evaluation request differently in watch mode and debug console mode, which all the debug adapters I tested don't do).

Also, I still don't know how the string is escaped. Is the output exactly This is a string? or "This is a string"? What happens with line breaks or double quotes inside the string? Are they escaped or not?

My extension tries to parse the output of the debug adapter. Every debug adapter slightly differs in how the string is escaped.

from vscode-debug-visualizer.

pakLebah avatar pakLebah commented on September 1, 2024

In the debugger panel, it’s printed as “This is a string” (with the double quote) to indicate that it’s a string, I think. But on the Terminal, it’s printed as This is a string (without the double quote).

I don’t quite understand how the debugger formats the output. What is the debugger extension you’re using on your VS Code?

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

What is the debugger extension you’re using on your VS Code?

I use node or chrome and they don't escape the string. If you use CodeLLDB, escaping should work, i.e. you can just visualize an expression that evaluates to a json string matching the schema of one of the visualizers.

from vscode-debug-visualizer.

pakLebah avatar pakLebah commented on September 1, 2024

you can just visualize an expression that evaluates to a json string matching the schema of one of the visualizers.

And how to do that? Every time I put a string variable I wanted to evaluate into the visualizer, it shows this error:

Error: Could not parse `<value>` as JSON. Unexpected token s in JSON at position 0

What should I do?

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

Is <value> valid json? It must be.

from vscode-debug-visualizer.

pakLebah avatar pakLebah commented on September 1, 2024

It’s just the "This is a string" I mentioned above.

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

As I mentioned before, the string needs to be json. This is a string is not json.

from vscode-debug-visualizer.

pakLebah avatar pakLebah commented on September 1, 2024

As I asked before, how to do that? I’ve tried the Text interface and it failed too. I forgot the error message because I’m not in front of my laptop now. The point is, this extension wouldn’t work out of the box with unsupported languages.

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

You do that by serializing a json object and storing the result in a string. What do you mean with "I've tried the text interface"? I'll try to improve the error messages. But it does work out of the box with a lot of languages like Java of C# that also don't have built in support.
Try visualizing this expression:

"{\"kind\":{\"graph\":true},\"nodes\":[{\"id\":\"1\"},{\"id\":\"2\"}],\"edges\":[{\"from\":\"1\",\"to\":\"2\"}]}"

from vscode-debug-visualizer.

hediet avatar hediet commented on September 1, 2024

I verified that this extension works with swift, using the lldb debugger:
image
You can find the demo here.

from vscode-debug-visualizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.