Skip to content

[wasm][debugger] View multidimensional array when debugging - #60983

Merged
thaystg merged 9 commits into
dotnet:mainfrom
thaystg:thays_multidimensional_array
Nov 16, 2021
Merged

[wasm][debugger] View multidimensional array when debugging#60983
thaystg merged 9 commits into
dotnet:mainfrom
thaystg:thays_multidimensional_array

Conversation

@thaystg

@thaystgthaystg commented Oct 28, 2021

Copy link
Copy Markdown
Member

Unfortunatelly as JS doesn't have mutidimensional arrays, I have to threat mutidimensional array as an object, as far as I understood for the user experience there isn't any difference in the behavior.

Before PR:
image

After PR on VS:
image

After PR on Chrome:
image

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1417072

@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

It's working when debug from chrome but not when debug from VS, because it uses callFunctionOn

Author:thaystg
Assignees:-
Labels:

area-Debugger-mono

Milestone:-

@radicalradical added the arch-wasm WebAssembly architecture label Oct 28, 2021
@ghost

Copy link
Copy Markdown

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

It's working when debug from chrome but not when debug from VS, because it uses callFunctionOn

Author:thaystg
Assignees:-
Labels:

arch-wasm, area-Debugger-mono

Milestone:-

@lewing

Copy link
Copy Markdown
Member

I really wonder why vscode-js-debug uses callFunctionOn rather than the protocol bits.

@thaystg
thaystg marked this pull request as ready for review November 3, 2021 15:06
@thaystg
thaystg requested review from lewing and radicalNovember 3, 2021 15:07
var length = retDebuggerCmdReader.ReadInt32();
length = retDebuggerCmdReader.ReadInt32();
return length;
var arrDimensions = new ArrayDimensions(length);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be var rank = new int[length] then new ArrayDimensions(rank) and forgo the resizing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And populate rank, before new ArrayDimensions, so TotalLength can be precomputed too. And ArrayDimensions can be a record.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

done.

return null;
}
public async Task<int> GetArrayLength(SessionId sessionId, int object_id, CancellationToken token)
public async Task<ArrayDimensions> GetArrayLength(SessionId sessionId, int object_id, CancellationToken token)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rename to GetArrayDimensions

for (int i = 0 ; i < length; i++)
{
rank[i] = retDebuggerCmdReader.ReadInt32();
retDebuggerCmdReader.ReadInt32();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this reading? comment would be helpful

commandParamsWriter.Write(arrayId);
commandParamsWriter.Write(0);
commandParamsWriter.Write(length);
commandParamsWriter.Write(length.TotalLength);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: length -> dimensions?

for (int i = 0 ; i < length.TotalLength; i++)
{
var var_json = await CreateJObjectForVariableValue(sessionId, retDebuggerCmdReader, i.ToString(), false, -1, false, token);
var var_json = await CreateJObjectForVariableValue(sessionId, retDebuggerCmdReader, length.GetArrayIndexString(i), false, -1, false, token);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: param name for the bools at least

arrayType = arrayType.Insert(arrayType.LastIndexOf('[')+1, length.ToString());
if (className.LastIndexOf('[') > 0)
className = className.Insert(arrayType.LastIndexOf('[')+1, new string(',', length.Rank-1));
return CreateJObject<string>(null, "object", arrayType, false, className.ToString(), "dotnet:array:" + objectId, null, length.Rank == 1 ? "array" : null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: param names, a bit confusing to read otherwise

var length = await GetArrayLength(sessionId, arrayId, token);
var arrayProxy = JObject.FromObject(new
{
items = await GetArrayValues(sessionId, arrayId, token),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GetArrayValues also calls GetArrayLength. Instead maybe GetArrayValues can return (JArray, ArrayDimensions), or it can take a `ArrayDimensions argument?

int boundLimit = 1;
int lastBoundLimit = 1;
int[] arrayStr = new int[Rank];
int rankStart = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check for idx < 0, and idx >= TotalLength

@radicalradical left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! thank you for your patience :)

@thaystg

Copy link
Copy Markdown
MemberAuthor

/backport to release/6.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1527691382

@github-actions

Copy link
Copy Markdown
Contributor

@thaystg backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: It's working when debug from chrome but not when debug from VS, because it uses callFunctionOnApplying: Remove unrelated change.Applying: Working also on VS.Applying: Working also on VS.Using index info to reconstruct a base tree...A	src/mono/wasm/runtime/debug.tsFalling back to patching base and 3-way merge...CONFLICT (modify/delete): src/mono/wasm/runtime/debug.ts deleted in HEAD and modified in Working also on VS.. Version Working also on VS. of src/mono/wasm/runtime/debug.ts left in tree.error: Failed to merge in the changes.hint: Use 'git am --show-current-patch=diff' to see the failed patchPatch failed at 0004 Working also on VS.When you have resolved this problem, run "git am --continue".If you prefer to skip this patch, run "git am --skip" instead.To restore the original branch and stop patching, run "git am --abort".Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@ghostghost locked as resolved and limited conversation to collaborators Jan 1, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Debugger-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@thaystg@lewing@radical