-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[wasm][debugger] View multidimensional array when debugging #60983
Conversation
…se it uses callFunctionOn
Tagging subscribers to this area: @thaystg Issue DetailsIt's working when debug from chrome but not when debug from VS, because it uses callFunctionOn
|
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIt's working when debug from chrome but not when debug from VS, because it uses callFunctionOn
|
I really wonder why vscode-js-debug uses callFunctionOn rather than the protocol bits. |
{ | ||
var commandParams = new MemoryStream(); | ||
var commandParamsWriter = new MonoBinaryWriter(commandParams); | ||
commandParamsWriter.Write(object_id); | ||
var retDebuggerCmdReader = await SendDebuggerAgentCommand<CmdArray>(sessionId, CmdArray.GetLength, commandParams, token); | ||
var length = retDebuggerCmdReader.ReadInt32(); | ||
length = retDebuggerCmdReader.ReadInt32(); | ||
return length; | ||
var arrDimensions = new ArrayDimensions(length); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -1451,15 +1501,20 @@ public async Task<string> GetStringValue(SessionId sessionId, int string_id, Can | |||
} | |||
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) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
@@ -2211,16 +2266,28 @@ public async Task<JArray> GetArrayValues(SessionId sessionId, int arrayId, Cance | |||
var commandParamsWriter = new MonoBinaryWriter(commandParams); | |||
commandParamsWriter.Write(arrayId); | |||
commandParamsWriter.Write(0); | |||
commandParamsWriter.Write(length); | |||
commandParamsWriter.Write(length.TotalLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: length
-> dimensions
?
{ | ||
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1527691382 |
@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 callFunctionOn
Applying: 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.ts
Falling 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 patch
Patch 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! |
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:
After PR on VS:
After PR on Chrome:
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1417072