Skip to content
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

[debugger][wasm] Support DebuggerProxyAttribute #56872

Merged
merged 15 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
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
2 changes: 1 addition & 1 deletion src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6459,7 +6459,7 @@ get_types (gpointer key, gpointer value, gpointer user_data)
t = mono_reflection_get_type_checked (alc, ass->image, ass->image, ud->info, ud->ignore_case, TRUE, &type_resolve, probe_type_error);
mono_error_cleanup (probe_type_error);
if (t) {
g_ptr_array_add (ud->res_classes, mono_type_get_class_internal (t));
g_ptr_array_add (ud->res_classes, mono_class_from_mono_type_internal (t));
g_ptr_array_add (ud->res_domains, domain);
}
}
Expand Down
29 changes: 25 additions & 4 deletions src/mono/sample/wasm/browser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Collections.Generic;

namespace Sample
{
Expand Down Expand Up @@ -37,6 +38,28 @@ string GetDebuggerDisplay ()
}
}

[DebuggerTypeProxy(typeof(TheProxy))]
class WithProxy
{
public string Val1 {
get { return "one"; }
}
}

class TheProxy
{
WithProxy wp;

public TheProxy (WithProxy wp)
{
this.wp = wp;
}

public string Val2 {
get { return wp.Val1; }
}
}

public static void Main(string[] args)
{
Console.WriteLine ("Hello, World!");
Expand All @@ -45,10 +68,8 @@ public static void Main(string[] args)
[MethodImpl(MethodImplOptions.NoInlining)]
public static int TestMeaning()
{
var a = new WithDisplayString();
var c = new DebuggerDisplayMethodTest();
Console.WriteLine(a);
Console.WriteLine(c);
List<int> myList = new List<int>{ 1, 2, 3, 4 };
Console.WriteLine(myList);
return 42;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<JObject> GetValueFromObject(JToken objRet, CancellationToken t
{
if (DotnetObjectId.TryParse(objRet?["value"]?["objectId"]?.Value<string>(), out DotnetObjectId objectId))
{
var exceptionObject = await proxy.SdbHelper.GetObjectValues(sessionId, int.Parse(objectId.Value), true, false, false, true, token);
var exceptionObject = await proxy.SdbHelper.GetObjectValues(sessionId, int.Parse(objectId.Value), GetObjectCommandType.WithProperties | GetObjectCommandType.OwnProperties, token);
var exceptionObjectMessage = exceptionObject.FirstOrDefault(attr => attr["name"].Value<string>().Equals("_message"));
exceptionObjectMessage["value"]["value"] = objRet["value"]?["className"]?.Value<string>() + ": " + exceptionObjectMessage["value"]?["value"]?.Value<string>();
return exceptionObjectMessage["value"]?.Value<JObject>();
Expand Down Expand Up @@ -88,7 +88,7 @@ public async Task<JObject> TryToRunOnLoadedClasses(string varName, CancellationT
classNameToFind += part.Trim();
if (typeId != -1)
{
var fields = await proxy.SdbHelper.GetTypeFields(sessionId, typeId, token);
var fields = await proxy.SdbHelper.GetTypeFields(sessionId, typeId, false, token);
foreach (var field in fields)
{
if (field.Name == part.Trim())
Expand Down
19 changes: 12 additions & 7 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,18 @@ private async Task<bool> OnSetVariableValue(MessageId id, int scopeId, string va
internal async Task<JToken> RuntimeGetPropertiesInternal(SessionId id, DotnetObjectId objectId, JToken args, CancellationToken token)
{
var accessorPropertiesOnly = false;
var ownProperties = false;
GetObjectCommandType objectValuesOpt = GetObjectCommandType.WithProperties;
if (args != null)
{
if (args["accessorPropertiesOnly"] != null)
accessorPropertiesOnly = args["accessorPropertiesOnly"].Value<bool>();
if (args["ownProperties"] != null)
ownProperties = args["ownProperties"].Value<bool>();
if (args["accessorPropertiesOnly"] != null && args["accessorPropertiesOnly"].Value<bool>())
{
objectValuesOpt |= GetObjectCommandType.AccessorPropertiesOnly;
accessorPropertiesOnly = true;
}
if (args["ownProperties"] != null && args["ownProperties"].Value<bool>())
{
objectValuesOpt |= GetObjectCommandType.OwnProperties;
}
}
//Console.WriteLine($"RuntimeGetProperties - {args}");
try {
Expand All @@ -639,7 +644,7 @@ internal async Task<JToken> RuntimeGetPropertiesInternal(SessionId id, DotnetObj
case "array":
return await SdbHelper.GetArrayValues(id, int.Parse(objectId.Value), token);
case "object":
return await SdbHelper.GetObjectValues(id, int.Parse(objectId.Value), true, false, accessorPropertiesOnly, ownProperties, token);
return await SdbHelper.GetObjectValues(id, int.Parse(objectId.Value), objectValuesOpt, token);
case "pointer":
return new JArray{await SdbHelper.GetPointerContent(id, int.Parse(objectId.Value), token)};
case "cfo_res":
Expand Down Expand Up @@ -911,7 +916,7 @@ private async Task<bool> OnReceiveDebuggerAgentEvent(SessionId sessionId, JObjec
string reason = "exception";
int object_id = retDebuggerCmdReader.ReadInt32();
var caught = retDebuggerCmdReader.ReadByte();
var exceptionObject = await SdbHelper.GetObjectValues(sessionId, object_id, true, false, false, true, token);
var exceptionObject = await SdbHelper.GetObjectValues(sessionId, object_id, GetObjectCommandType.WithProperties | GetObjectCommandType.OwnProperties, token);
var exceptionObjectMessage = exceptionObject.FirstOrDefault(attr => attr["name"].Value<string>().Equals("message"));
var data = JObject.FromObject(new
{
Expand Down
Loading