-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[wasm][debugger] Fixing race condition #64394
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
Changes from 3 commits
f2a2027
7921a85
bc4dde4
532ee06
743791c
e511ff9
a183c57
b1e1f68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -700,7 +700,7 @@ public PointerValue(long address, int typeId, string varName) | |
| internal class MonoSDBHelper | ||
| { | ||
| private static int debuggerObjectId; | ||
| private static int cmdId; | ||
| private static int cmdId = 1; | ||
| private static int GetId() {return cmdId++;} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this to |
||
| private static int MINOR_VERSION = 61; | ||
| private static int MAJOR_VERSION = 2; | ||
|
|
@@ -2180,6 +2180,7 @@ public async Task<JArray> GetValueTypeProxy(int valueTypeId, CancellationToken t | |
| command = CmdVM.InvokeMethod, | ||
| buffer = data, | ||
| length = length, | ||
| id = GetId() | ||
| }), | ||
| name = propertyNameStr | ||
| })); | ||
|
|
@@ -2505,7 +2506,8 @@ async Task<JArray> GetFieldsValues(List<FieldTypeClass> fields, bool isOwn, bool | |
| command = CmdObject.RefSetValues, | ||
| buffer = data, | ||
| valtype, | ||
| length = length | ||
| length, | ||
| id = GetId() | ||
| })); | ||
| } | ||
| if (!isRootHidden) | ||
|
|
@@ -2636,7 +2638,8 @@ public async Task<JArray> GetObjectProxy(int objectId, CancellationToken token) | |
| command = CmdVM.InvokeMethod, | ||
| buffer = data, | ||
| valtype = attr["set"]["valtype"], | ||
| length = length | ||
| length, | ||
| id = GetId() | ||
| }); | ||
| } | ||
| continue; | ||
|
|
@@ -2655,7 +2658,8 @@ public async Task<JArray> GetObjectProxy(int objectId, CancellationToken token) | |
| commandSet = CommandSet.Vm, | ||
| command = CmdVM.InvokeMethod, | ||
| buffer = data, | ||
| length = length | ||
| length = length, | ||
| id = GetId() | ||
| }), | ||
| name = propertyNameStr | ||
| })); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { toBase64StringImpl } from "./base64"; | |
| import cwraps from "./cwraps"; | ||
| import { VoidPtr, CharPtr } from "./types/emscripten"; | ||
|
|
||
| let commands_received: CommandResponse; | ||
| const commands_received = new Map<number, CommandResponse>(); | ||
| let _call_function_res_cache: any = {}; | ||
| let _next_call_function_res_id = 0; | ||
| let _debugger_buffer_len = -1; | ||
|
|
@@ -43,7 +43,7 @@ export function mono_wasm_add_dbg_command_received(res_ok: boolean, id: number, | |
| value: base64String | ||
| } | ||
| }; | ||
| commands_received = buffer_obj; | ||
| commands_received.set(id, buffer_obj); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if there is an existing entry for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if there is, should I print a warning? |
||
| } | ||
|
|
||
| function mono_wasm_malloc_and_set_debug_buffer(command_parameters: string) { | ||
|
|
@@ -63,7 +63,8 @@ export function mono_wasm_send_dbg_command_with_parms(id: number, command_set: n | |
| mono_wasm_malloc_and_set_debug_buffer(command_parameters); | ||
| cwraps.mono_wasm_send_dbg_command_with_parms(id, command_set, command, _debugger_buffer, length, valtype, newvalue.toString()); | ||
|
|
||
| const { res_ok, res } = commands_received; | ||
| const { res_ok, res } = commands_received.get(id) as CommandResponse; | ||
| commands_received.delete(id); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest making a method that combines get and delete |
||
| if (!res_ok) | ||
| throw new Error("Failed on mono_wasm_invoke_method_debugger_agent_with_parms"); | ||
| return res; | ||
|
|
@@ -73,15 +74,17 @@ export function mono_wasm_send_dbg_command(id: number, command_set: number, comm | |
| mono_wasm_malloc_and_set_debug_buffer(command_parameters); | ||
| cwraps.mono_wasm_send_dbg_command(id, command_set, command, _debugger_buffer, command_parameters.length); | ||
|
|
||
| const { res_ok, res } = commands_received; | ||
| const { res_ok, res } = commands_received.get(id) as CommandResponse; | ||
| commands_received.delete(id); | ||
| if (!res_ok) | ||
| throw new Error("Failed on mono_wasm_send_dbg_command"); | ||
| return res; | ||
|
|
||
| } | ||
|
|
||
| export function mono_wasm_get_dbg_command_info(): CommandResponseResult { | ||
| const { res_ok, res } = commands_received; | ||
| const { res_ok, res } = commands_received.get(0) as CommandResponse; | ||
| commands_received.delete(0); | ||
| if (!res_ok) | ||
| throw new Error("Failed on mono_wasm_get_dbg_command_info"); | ||
| return res; | ||
|
|
@@ -134,10 +137,10 @@ function _create_proxy_from_object_id(objectId: string, details: any) { | |
| prop.name, | ||
| { | ||
| get() { | ||
| return mono_wasm_send_dbg_command(-1, prop.get.commandSet, prop.get.command, prop.get.buffer); | ||
| return mono_wasm_send_dbg_command(prop.get.id, prop.get.commandSet, prop.get.command, prop.get.buffer); | ||
| }, | ||
| set: function (newValue) { | ||
| mono_wasm_send_dbg_command_with_parms(-1, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return commands_received.res_ok; | ||
| mono_wasm_send_dbg_command_with_parms(prop.set.id, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return true; | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -149,7 +152,7 @@ function _create_proxy_from_object_id(objectId: string, details: any) { | |
| return prop.value; | ||
| }, | ||
| set: function (newValue) { | ||
| mono_wasm_send_dbg_command_with_parms(-1, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return commands_received.res_ok; | ||
| mono_wasm_send_dbg_command_with_parms(prop.set.id, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return true; | ||
| } | ||
| } | ||
| ); | ||
|
|
||
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.
cmdId == 0is a special one now. Can you add a comment for that here?