Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/mono/mono/component/mini-wasm-debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,21 +356,20 @@ mono_wasm_set_is_debugger_attached (gboolean is_attached)
}

extern void mono_wasm_add_dbg_command_received(mono_bool res_ok, int id, void* buffer, int buffer_len);
extern void mono_wasm_add_dbg_command_result(mono_bool res_ok, int id, void* buffer, int buffer_len);

EMSCRIPTEN_KEEPALIVE gboolean
mono_wasm_send_dbg_command_with_parms (int id, MdbgProtCommandSet command_set, int command, guint8* data, unsigned int size, int valtype, char* newvalue)
{
if (!debugger_enabled) {
EM_ASM ({
MONO.mono_wasm_add_dbg_command_received ($0, $1, $2, $3);
}, 0, id, 0, 0);
mono_wasm_add_dbg_command_result (0, id, 0, 0);
return TRUE;
}
MdbgProtBuffer bufWithParms;
buffer_init (&bufWithParms, 128);
m_dbgprot_buffer_add_data (&bufWithParms, data, size);
if (!write_value_to_buffer(&bufWithParms, valtype, newvalue)) {
mono_wasm_add_dbg_command_received(0, id, 0, 0);
mono_wasm_add_dbg_command_result(0, id, 0, 0);
return TRUE;
}
mono_wasm_send_dbg_command(id, command_set, command, bufWithParms.buf, m_dbgprot_buffer_len(&bufWithParms));
Expand All @@ -382,9 +381,7 @@ EMSCRIPTEN_KEEPALIVE gboolean
mono_wasm_send_dbg_command (int id, MdbgProtCommandSet command_set, int command, guint8* data, unsigned int size)
{
if (!debugger_enabled) {
EM_ASM ({
MONO.mono_wasm_add_dbg_command_received ($0, $1, $2, $3);
}, 0, id, 0, 0);
mono_wasm_add_dbg_command_result(0, id, 0, 0);
return TRUE;
}
ss_calculate_framecount (NULL, NULL, TRUE, NULL, NULL);
Expand All @@ -403,7 +400,7 @@ mono_wasm_send_dbg_command (int id, MdbgProtCommandSet command_set, int command,
else
error = mono_process_dbg_packet (id, command_set, command, &no_reply, data, data + size, &buf);

mono_wasm_add_dbg_command_received(error == MDBGPROT_ERR_NONE, id, buf.buf, buf.p-buf.buf);
mono_wasm_add_dbg_command_result (error == MDBGPROT_ERR_NONE, id, buf.buf, buf.p-buf.buf);

buffer_free (&buf);
return TRUE;
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/runtime/cjs/dotnet.cjs.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const linked_functions = [
"mono_wasm_fire_debugger_agent_message",
"mono_wasm_debugger_log",
"mono_wasm_add_dbg_command_received",
"mono_wasm_add_dbg_command_result",

// mono-threads-wasm.c
"schedule_background_exec",
Expand Down
22 changes: 18 additions & 4 deletions src/mono/wasm/runtime/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cwraps from "./cwraps";
import { VoidPtr, CharPtr } from "./types/emscripten";

let commands_received: CommandResponse;
let commands_result: CommandResponse;
let _call_function_res_cache: any = {};
let _next_call_function_res_id = 0;
let _debugger_buffer_len = -1;
Expand Down Expand Up @@ -46,6 +47,19 @@ export function mono_wasm_add_dbg_command_received(res_ok: boolean, id: number,
commands_received = buffer_obj;
}

export function mono_wasm_add_dbg_command_result(res_ok: boolean, id: number, buffer: number, buffer_len: number): void {
const assembly_data = new Uint8Array(Module.HEAPU8.buffer, buffer, buffer_len);
const base64String = toBase64StringImpl(assembly_data);
const buffer_obj = {
res_ok,
res: {
id,
value: base64String
}
};
commands_result = buffer_obj;
}

function mono_wasm_malloc_and_set_debug_buffer(command_parameters: string) {
if (command_parameters.length > _debugger_buffer_len) {
if (_debugger_buffer)
Expand All @@ -63,7 +77,7 @@ 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_result;
if (!res_ok)
throw new Error("Failed on mono_wasm_invoke_method_debugger_agent_with_parms");
return res;
Expand All @@ -73,7 +87,7 @@ 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_result;
if (!res_ok)
throw new Error("Failed on mono_wasm_send_dbg_command");
return res;
Expand Down Expand Up @@ -137,7 +151,7 @@ function _create_proxy_from_object_id(objectId: string, details: any) {
return mono_wasm_send_dbg_command(-1, 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(-1, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return commands_result.res_ok;
}
}
);
Expand All @@ -149,7 +163,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(-1, prop.set.commandSet, prop.set.command, prop.set.buffer, prop.set.length, prop.set.valtype, newValue); return commands_result.res_ok;
}
}
);
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/runtime/es6/dotnet.es6.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const linked_functions = [
"mono_wasm_fire_debugger_agent_message",
"mono_wasm_debugger_log",
"mono_wasm_add_dbg_command_received",
"mono_wasm_add_dbg_command_result",

// mono-threads-wasm.c
"schedule_background_exec",
Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasm/runtime/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
mono_wasm_debugger_log,
mono_wasm_trace_logger,
mono_wasm_add_dbg_command_received,
mono_wasm_add_dbg_command_result,
} from "./debug";
import { runtimeHelpers, setImportsAndExports } from "./imports";
import { DotnetModuleConfigImports, DotnetModule } from "./types";
Expand Down Expand Up @@ -266,6 +267,7 @@ export const __linker_exports: any = {
mono_wasm_fire_debugger_agent_message,
mono_wasm_debugger_log,
mono_wasm_add_dbg_command_received,
mono_wasm_add_dbg_command_result,

// mono-threads-wasm.c
schedule_background_exec,
Expand Down