Skip to content
Merged
Prev Previous commit
Next Next commit
Changing what was suggested by @radical
  • Loading branch information
thaystg committed Sep 22, 2021
commit 8fd17bb47f84246a674f8cc2721ac1ac7ca3f6fb
23 changes: 10 additions & 13 deletions src/mono/wasm/runtime/library_mono.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,24 +601,21 @@ var MonoSupportLib = {

mono_wasm_malloc_and_set_debug_buffer: function (command_parameters)
{
if (!this.debugger_buffer || command_parameters.length > this.debugger_buffer_len)
if (command_parameters.length > this._debugger_buffer_len)
{
if (this.debugger_buffer)
Module._free (this.debugger_buffer);
else
this.debugger_buffer_len = 256;
if (this.debugger_buffer_len < command_parameters.length)
this.debugger_buffer_len = command_parameters.length;
this.debugger_buffer = Module._malloc (this.debugger_buffer_len);
this.heap_bytes = new Uint8Array (Module.HEAPU8.buffer, this.debugger_buffer, this.debugger_buffer_len);
if (this._debugger_buffer)
Module._free (this._debugger_buffer);
this._debugger_buffer_len = Math.max(command_parameters.length, this._debugger_buffer_len, 256);
this._debugger_buffer = Module._malloc (this._debugger_buffer_len);
this._debugger_heap_bytes = new Uint8Array (Module.HEAPU8.buffer, this._debugger_buffer, this._debugger_buffer_len);
}
this.heap_bytes.set(this._base64_to_uint8 (command_parameters));
this._debugger_heap_bytes.set(this._base64_to_uint8 (command_parameters));
},

mono_wasm_send_dbg_command_with_parms: function (id, command_set, command, command_parameters, length, valtype, newvalue)
{
this.mono_wasm_malloc_and_set_debug_buffer(command_parameters);
this._c_fn_table.mono_wasm_send_dbg_command_with_parms_wrapper (id, command_set, command, this.debugger_buffer, length, valtype, newvalue.toString());
this._c_fn_table.mono_wasm_send_dbg_command_with_parms_wrapper (id, command_set, command, this._debugger_buffer, length, valtype, newvalue.toString());
let { res_ok, res } = MONO.commands_received;
if (!res_ok)
throw new Error (`Failed on mono_wasm_invoke_method_debugger_agent_with_parms`);
Expand All @@ -628,7 +625,7 @@ var MonoSupportLib = {
mono_wasm_send_dbg_command: function (id, command_set, command, command_parameters)
{
this.mono_wasm_malloc_and_set_debug_buffer(command_parameters);
this._c_fn_table.mono_wasm_send_dbg_command_wrapper (id, command_set, command, this.debugger_buffer, command_parameters.length);
this._c_fn_table.mono_wasm_send_dbg_command_wrapper (id, command_set, command, this._debugger_buffer, command_parameters.length);
let { res_ok, res } = MONO.commands_received;
if (!res_ok)
throw new Error (`Failed on mono_wasm_send_dbg_command`);
Expand Down Expand Up @@ -863,7 +860,7 @@ var MonoSupportLib = {
this._c_fn_table = {};
this._register_c_fn ('mono_wasm_send_dbg_command', 'bool', [ 'number', 'number', 'number', 'number', 'number' ]);
this._register_c_fn ('mono_wasm_send_dbg_command_with_parms', 'bool', [ 'number', 'number', 'number', 'number', 'number', 'number', 'string' ]);

this._debugger_buffer_len = -1;
// DO NOT REMOVE - magic debugger init function
if (globalThis.dotnetDebugger)
debugger;
Expand Down