vscode-debug-visualizer icon indicating copy to clipboard operation
vscode-debug-visualizer copied to clipboard

request: more visibility into JSON parsing errors

Open phrohdoh opened this issue 5 years ago • 15 comments

With this (completely valid and schema-compliant (AstTreeVisualizationData), AFAICT) JSON

{"kind":{"ast":true,"tree":true,"text":true},"root":{"items":[{"text":"exploding-barrel:"}],"children":[{"items":[{"text":"Tooltip:"}],"children":[],"span":{"start":18,"length":13},"segment":"todo"},{"items":[{"text":"Name: barrels"}],"children":[],"span":{"start":31,"length":22},"segment":"todo"},{"items":[{"text":"Health:"}],"children":[],"span":{"start":53,"length":12},"segment":"todo"},{"items":[{"text":"HP: 5"}],"children":[],"span":{"start":65,"length":14},"segment":"todo"},{"items":[{"text":"Explodes:"}],"children":[],"span":{"start":79,"length":14},"segment":"todo"},{"items":[{"text":"Weapon: large-barrel-explode"}],"children":[],"span":{"start":93,"length":37},"segment":"todo"},{"items":[{"text":"MapEditorData:"}],"children":[],"span":{"start":130,"length":19},"segment":"todo"},{"items":[{"text":"Categories: props, dangerous-props"}],"children":[],"span":{"start":149,"length":43},"segment":"todo"}],"span":{"start":0,"length":193},"segment":"doc-root"},"text":"exploding-barrel:\n    Tooltip:\n        Name: barrels\n    Health:\n        HP: 5\n    Explodes:\n        Weapon: large-barrel-explode\n    MapEditorData:\n        Categories: props, dangerous-props\n"}

I am getting the following parse error:

Screen Shot 2020-08-30 at 8 36 08 AM

Given my JSON is valid, I'm just stuck. I don't know what to change (and why) to give the visualizer what it wants.

Any insight and ideas on improving this greatly appreciated!

phrohdoh avatar Aug 30 '20 13:08 phrohdoh

It looks like it tries to parse it as string ("{") and then encounters the k.

What is the difference to https://github.com/hediet/vscode-debug-visualizer/pull/75?

hediet avatar Aug 30 '20 13:08 hediet

My guess is that lldb shortens long strings. The debug visualizer extension is trying out various ways how to parse the string (it tries to remove any surrounding quotation mark), but only reports the last one. So there might be a different json parse error. Can to copy the entire text of the error message and paste it here?

hediet avatar Aug 30 '20 13:08 hediet

Yeah, it looks like lldb truncates 🤦.

Could not parse evaluation result as JSON:

Unexpected token k in JSON at position 3

Evaluation result was:
"{"kind":{"ast":true,"tree":true,"text":true},"root":{"items":[{"text":"exploding-barrel:"}],"children":[{"items":[{"text":"Tooltip:"}],"children":[],"span":{"start":18,"length":13},"segment":"todo"},{"items":[{"text":"Name: barrels"}],"children":[],"span":{"start":31,"length":22},"segment":"todo"},{"items":[{"text":"Health:"}],"children":[],"span":{"start":53,"length":12},"segment":"todo"},{"items":[{"text":"HP: 5"}],"children":[],"span":{"start":65,"length":14},"segment":"todo"},{"items":[{"text":"Explodes:"}],"children":[],"span":{"start":79,"length":14},"segment":"todo"},{"items":[{"text":"Weapon: large-barrel-explode"}],"children":[],"span":{"start":93,"length":37},"segment":"todo"},{"items":[{"text":"MapEditorData:"}],"children":[],"span":{"start":130,"length":19},"segment":"todo"},{"items":[{"text":"Categories: props, dangerous-props"}],"children":[],"span":{"start":149,"length":43},"segment":"todo"}],"span":{"start":0,"length":193},"segment":"doc-root"},"text":"exploding-barrel:..."

Used debug adapter: lldb

phrohdoh avatar Aug 30 '20 13:08 phrohdoh

https://stackoverflow.com/a/41600000 may be what we want in this case.

phrohdoh avatar Aug 30 '20 14:08 phrohdoh

Or this one: https://stackoverflow.com/questions/31402092/print-long-string-in-xcode-6-debugging-console

hediet avatar Aug 30 '20 14:08 hediet

https://github.com/vadimcn/vscode-lldb/blob/master/MANUAL.md#launching-a-new-process

I think initCommands can be used to configure these things.

hediet avatar Aug 30 '20 14:08 hediet

Setting target.max-string-summary-length to 10000 (via initCommands) seems to make no difference, the string is still truncated (with ... appended) at the exact same position.

edit: confirmed that max-string-summary-length is indeed being set to 10000 (via initCommands) by executing settings show target.max-string-summary-length in VSCode's debug console, which prints target.max-string-summary-length (int) = 10000.

phrohdoh avatar Aug 30 '20 14:08 phrohdoh

Your string is truncated after exactly 1000 chars. Maybe you can reverse search a setting that has that value.

hediet avatar Aug 30 '20 14:08 hediet

This article also uses target.max-string-summary-length. Is the watch windows also truncating the string? What about the debug console?

hediet avatar Aug 30 '20 14:08 hediet

AFAIK the watch viewlet and debug console are driven by the debug adapter. Yes, both of them display the truncated value.

I do not have any lldb settings with the value 1000 (confirmed by running settings show and searching over the result).

phrohdoh avatar Aug 30 '20 14:08 phrohdoh

AFAIK the watch viewlet and debug console are driven by the debug adapter.

Yes, this extension is driven too by the debug adapter. However, the watch viewlet uses the watch context, the debug console the repl context, and this extension by default also the repl context (that you overwrote with watch).

hediet avatar Aug 30 '20 14:08 hediet

I do not have any lldb settings with the value 1000 (confirmed by running settings show and searching over the result).

This is unfortunate. If you make it work in the repl context with long strings (maybe there is some special formatting argument), I could extend the json parsing logic to deal with lldb outputs.

If lldb has no way to output long strings, this extension cannot do much.

hediet avatar Aug 30 '20 14:08 hediet

This is indeed unfortunate. Thank you for your help and time!

phrohdoh avatar Aug 30 '20 14:08 phrohdoh

I think your main point is still valid. The error reporting is still not good.

hediet avatar Aug 30 '20 15:08 hediet