From 22460e4a97b3cb4549c29f70eacbbc96ba0bab2e Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 28 Sep 2021 11:32:03 -0300 Subject: [PATCH 1/5] Debugger was broken. --- src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 6c1ad7cf757d9f..8c9f9f4f7391a3 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -177,6 +177,7 @@ protected override async Task AcceptEvent(SessionId sessionId, string meth await SendCommand(sessionId, "Debugger.resume", new JObject(), token); return true; } + case "mono_wasm_fire_debugger_agent_message": case "_mono_wasm_fire_debugger_agent_message": { try { From 67dc6d984d062756a80e1deb09390eaa1d38cb12 Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 28 Sep 2021 12:15:12 -0300 Subject: [PATCH 2/5] Reverting usage of local_eval. --- src/mono/wasm/runtime/src/mono/debug.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/runtime/src/mono/debug.ts b/src/mono/wasm/runtime/src/mono/debug.ts index 9f097b8933cfa8..8019ab1dce0f2b 100644 --- a/src/mono/wasm/runtime/src/mono/debug.ts +++ b/src/mono/wasm/runtime/src/mono/debug.ts @@ -145,7 +145,7 @@ export function mono_wasm_call_function_on(request: CallRequest) { const objId = request.objectId; const details = request.details; - let proxy; + let proxy: any = {}; if (objId.startsWith('dotnet:cfo_res:')) { if (objId in _call_function_res_cache) @@ -159,8 +159,7 @@ export function mono_wasm_call_function_on(request: CallRequest) { const fn_args = request.arguments != undefined ? request.arguments.map(a => JSON.stringify(a.value)) : []; const fn_eval_str = `var fn = ${request.functionDeclaration}; fn.call (proxy, ...[${fn_args}]);`; - const local_eval = eval; // https://rollupjs.org/guide/en/#avoiding-eval - const fn_res = local_eval(fn_eval_str); + const fn_res = eval(fn_eval_str); if (fn_res === undefined) return { type: "undefined" }; From 67b628327e2f8b3dd2f89c2dd8360c796e54a0ad Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 28 Sep 2021 14:24:43 -0300 Subject: [PATCH 3/5] Addressing @lambdageek suggestion. --- src/mono/wasm/runtime/src/mono/debug.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/runtime/src/mono/debug.ts b/src/mono/wasm/runtime/src/mono/debug.ts index 8019ab1dce0f2b..e4b7accd58df70 100644 --- a/src/mono/wasm/runtime/src/mono/debug.ts +++ b/src/mono/wasm/runtime/src/mono/debug.ts @@ -157,9 +157,11 @@ export function mono_wasm_call_function_on(request: CallRequest) { } const fn_args = request.arguments != undefined ? request.arguments.map(a => JSON.stringify(a.value)) : []; - const fn_eval_str = `var fn = ${request.functionDeclaration}; fn.call (proxy, ...[${fn_args}]);`; - const fn_res = eval(fn_eval_str); + const fn_body_template = `var fn = ${request.functionDeclaration}; return fn.call (proxy, ...[${fn_args}]);`; + const fn_defn = new Function ('proxy', fn_body_template); + const fn_res = fn_defn (proxy); + if (fn_res === undefined) return { type: "undefined" }; From b58d7ef844a326291a526cffa65ebe7c42837adb Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 28 Sep 2021 15:09:36 -0300 Subject: [PATCH 4/5] Addressing @kg comment. --- src/mono/wasm/runtime/src/mono/debug.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/runtime/src/mono/debug.ts b/src/mono/wasm/runtime/src/mono/debug.ts index e4b7accd58df70..eb5b54fd6affdd 100644 --- a/src/mono/wasm/runtime/src/mono/debug.ts +++ b/src/mono/wasm/runtime/src/mono/debug.ts @@ -158,7 +158,7 @@ export function mono_wasm_call_function_on(request: CallRequest) { const fn_args = request.arguments != undefined ? request.arguments.map(a => JSON.stringify(a.value)) : []; - const fn_body_template = `var fn = ${request.functionDeclaration}; return fn.call (proxy, ...[${fn_args}]);`; + const fn_body_template = `var fn = ${request.functionDeclaration}; return fn.apply (proxy, [${fn_args}]);`; const fn_defn = new Function ('proxy', fn_body_template); const fn_res = fn_defn (proxy); From cd2d62c63f4694f285d191ea96eacf198e6e81ce Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 28 Sep 2021 15:11:03 -0300 Subject: [PATCH 5/5] Fix spacing before parentheses. --- src/mono/wasm/runtime/src/mono/debug.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/runtime/src/mono/debug.ts b/src/mono/wasm/runtime/src/mono/debug.ts index eb5b54fd6affdd..5a9dca15c44edc 100644 --- a/src/mono/wasm/runtime/src/mono/debug.ts +++ b/src/mono/wasm/runtime/src/mono/debug.ts @@ -158,9 +158,9 @@ export function mono_wasm_call_function_on(request: CallRequest) { const fn_args = request.arguments != undefined ? request.arguments.map(a => JSON.stringify(a.value)) : []; - const fn_body_template = `var fn = ${request.functionDeclaration}; return fn.apply (proxy, [${fn_args}]);`; - const fn_defn = new Function ('proxy', fn_body_template); - const fn_res = fn_defn (proxy); + const fn_body_template = `var fn = ${request.functionDeclaration}; return fn.apply(proxy, [${fn_args}]);`; + const fn_defn = new Function('proxy', fn_body_template); + const fn_res = fn_defn(proxy); if (fn_res === undefined) return { type: "undefined" };