未验证 提交 9b9ccf84 编写于 作者: A Ankit Jain 提交者: GitHub

[wasm] Misc fixes (#73662)

- Change base url used for generated code
- Emit message about initial memory size, on native builds
- Don't trigger all the mono jobs based on changes in `src/mono/wasm/debugger`
- Also, truncate all protocol log messages to max line length of 64k. This reduces the proxy log file for tests from `1.0G` to `160M`.
  - truncating can be disabled by setting the environment variable `WASM_DONT_TRUNCATE_LOG_MESSAGES=1`.

Fixes #71727
Fixes #62736
上级 87d5ece7
......@@ -45,6 +45,7 @@ jobs:
- src/libraries/*
- src/native/libs/*
- src/tests/*
- src/mono/wasm/debugger/*
- eng/pipelines/installer/*
- eng/pipelines/coreclr/*
- eng/pipelines/libraries/*
......
......@@ -414,6 +414,7 @@
DependsOnTargets="_CheckEmccIsExpectedVersion;_WasmSelectRuntimeComponentsForLinking;_WasmCompileAssemblyBitCodeFilesForAOT;_WasmWriteRspFilesForLinking"
Returns="@(FileWrites)" >
<Message Text="Linking for initial memory %24(EmccInitialHeapSize)=$(EmccInitialHeapSize) bytes. Set this msbuild property to change the value." Importance="High" />
<Message Text="Linking with emcc with $(EmccLinkOptimizationFlag). This may take a while ..." Importance="High" />
<Message Text="Running emcc with @(_EmccLinkStepArgs->'%(Identity)', ' ')" Importance="Low" />
<Exec Command='emcc "@$(_EmccDefaultFlagsRsp)" "@$(_EmccDefaultLinkFlagsRsp)" "@$(_EmccLinkRsp)"' EnvironmentVariables="@(EmscriptenEnvVars)" />
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable enable
using System;
using Newtonsoft.Json.Linq;
namespace Microsoft.WebAssembly.Diagnostics;
internal static class HelperExtensions
{
private const int MaxLogMessageLineLength = 65536;
private static readonly bool TruncateLogMessages = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WASM_DONT_TRUNCATE_LOG_MESSAGES"));
public static string Truncate(this string message, int maxLen, string suffix = "")
=> string.Concat(message.Substring(0, Math.Min(message.Length, maxLen)).AsSpan(),
message.Length > maxLen ? suffix : "");
public static string TruncateLogMessage(this string message)
=> TruncateLogMessages
? message.Truncate(MaxLogMessageLineLength, ".. truncated")
: message;
public static void AddRange(this JArray arr, JArray addedArr)
{
foreach (var item in addedArr)
arr.Add(item);
}
public static bool IsNullValuedObject(this JObject obj)
=> obj != null && obj["type"]?.Value<string>() == "object" && obj["subtype"]?.Value<string>() == "null";
}
......@@ -49,7 +49,7 @@ protected virtual Task<bool> AcceptCommand(MessageId id, JObject args, Cancellat
protected Task Send(DevToolsQueue queue, JObject o, CancellationToken token)
{
logger.LogTrace($"to-{queue.Id}: {GetFromOrTo(o)} {o}");
Log("protocol", $"to-{queue.Id}: {GetFromOrTo(o)} {o}");
var msg = o.ToString(Formatting.None);
var bytes = Encoding.UTF8.GetBytes(msg);
......@@ -275,6 +275,9 @@ protected async Task RunLoopAsync(WasmDebuggerConnection ideConn, WasmDebuggerCo
protected void Log(string priority, string msg)
{
if (priority == "protocol")
msg = msg.TruncateLogMessage();
switch (priority)
{
case "protocol":
......
......@@ -1235,11 +1235,7 @@ private async Task<bool> OnJSEventRaised(SessionId sessionId, JObject eventArgs,
return false;
}
string eventStr = eventArgs.ToString();
string newStr = eventStr.Substring(0, Math.Min(1024, eventStr.Length));
if (newStr.Length != eventStr.Length)
newStr += " ... truncated }";
logger.LogDebug($"OnJsEventRaised: args: {newStr}");
logger.LogDebug($"OnJsEventRaised: args: {eventArgs.ToString().TruncateLogMessage()}");
switch (eventName)
{
......
......@@ -2368,17 +2368,4 @@ public static bool IsPrimitiveType(string simplifiedClassName)
=> s_primitiveTypeNames.Contains(simplifiedClassName);
}
internal static class HelperExtensions
{
public static void AddRange(this JArray arr, JArray addedArr)
{
foreach (var item in addedArr)
arr.Add(item);
}
public static bool IsNullValuedObject(this JObject obj)
=> obj != null && obj["type"]?.Value<string>() == "object" && obj["subtype"]?.Value<string>() == "null";
}
}
......@@ -60,7 +60,7 @@ public async Task DebugHotReloadMethodAddBreakpoint()
Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"),
Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"),
Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"),
"MethodBody3", "StaticMethod3", expectBpResolvedEvent: false);
"MethodBody3", "StaticMethod3", expectBpResolvedEvent: true);
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
CheckNumber(locals, "a", 10);
......
# Wasm debugger
## Debug proxy
- Protocol messages are truncated when logged, to 64k, by default. But this can be changed by setting `WASM_DONT_TRUNCATE_LOG_MESSAGES=1`.
......@@ -57,7 +57,7 @@ export function mono_wasm_bind_cs_function(fully_qualified_name: MonoStringRef,
invoke_method_and_handle_exception
};
const bound_js_function_name = "_bound_cs_" + `${namespace}_${classname}_${methodname}`.replace(/\./g, "_").replace(/\//g, "_");
let body = `//# sourceURL=https://mono-wasm.invalid/${bound_js_function_name} \n`;
let body = `//# sourceURL=https://dotnet.generated.invalid/${bound_js_function_name} \n`;
let bodyToCs = "";
let converter_names = "";
......@@ -184,4 +184,4 @@ export function parseFQN(fqn: string)
if (!methodname.trim())
throw new Error("No method name specified " + fqn);
return { assembly, namespace, classname, methodname };
}
\ No newline at end of file
}
......@@ -31,7 +31,7 @@ export function mono_wasm_bind_js_function(function_name: MonoStringRef, module_
const closure: any = { fn, marshal_exception_to_cs, signature };
const bound_js_function_name = "_bound_js_" + js_function_name.replace(/\./g, "_");
let body = `//# sourceURL=https://mono-wasm.invalid/${bound_js_function_name} \n`;
let body = `//# sourceURL=https://dotnet.generated.invalid/${bound_js_function_name} \n`;
let converter_names = "";
......
......@@ -64,7 +64,7 @@ export function _create_rebindable_named_function(name: string, argumentNames: s
let uriPrefix = "", escapedFunctionIdentifier = "";
if (name) {
uriPrefix = "//# sourceURL=https://mono-wasm.invalid/" + name + "\r\n";
uriPrefix = "//# sourceURL=https://dotnet.generated.invalid/" + name + "\r\n";
escapedFunctionIdentifier = name;
} else {
escapedFunctionIdentifier = "unnamed";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册