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
Prev Previous commit
Next Next commit
Implementing getting property and checking failures.
  • Loading branch information
thaystg committed Aug 2, 2021
commit 4608fad76cccb9f394489d81a28cc704a7c33cac
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public async Task<JObject> TryToRunOnLoadedClasses(string varName, CancellationT
return await GetValueFromObject(valueRet, token);
}
}
var methodId = await proxy.SdbHelper.GetPropertyMethodIdByName(sessionId, typeId, part.Trim(), token);
if (methodId != -1)
{
var commandParamsObj = new MemoryStream();
var commandParamsObjWriter = new MonoBinaryWriter(commandParamsObj);
commandParamsObjWriter.Write(0); //param count
var retMethod = await proxy.SdbHelper.InvokeMethod(sessionId, commandParamsObj.ToArray(), methodId, "methodRet", token);
return await GetValueFromObject(retMethod, token);
}
}
var store = await proxy.LoadStore(sessionId, token);
foreach (var asm in store.assemblies)
Expand Down
24 changes: 24 additions & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,30 @@ public async Task<JObject> InvokeMethod(SessionId sessionId, byte[] valueTypeBuf
retDebuggerCmdReader.ReadByte(); //number of objects returned.
return await CreateJObjectForVariableValue(sessionId, retDebuggerCmdReader, varName, false, -1, token);
}

public async Task<int> GetPropertyMethodIdByName(SessionId sessionId, int typeId, string propertyName, CancellationToken token)
{
var commandParams = new MemoryStream();
var commandParamsWriter = new MonoBinaryWriter(commandParams);
commandParamsWriter.Write(typeId);

var retDebuggerCmdReader = await SendDebuggerAgentCommand<CmdType>(sessionId, CmdType.GetProperties, commandParams, token);
var nProperties = retDebuggerCmdReader.ReadInt32();
for (int i = 0 ; i < nProperties; i++)
{
retDebuggerCmdReader.ReadInt32(); //propertyId
string propertyNameStr = retDebuggerCmdReader.ReadString();
var getMethodId = retDebuggerCmdReader.ReadInt32();
retDebuggerCmdReader.ReadInt32(); //setmethod
var attrs = retDebuggerCmdReader.ReadInt32(); //attrs
if (propertyNameStr == propertyName)
{
return getMethodId;
}
}
return -1;
}

public async Task<JArray> CreateJArrayForProperties(SessionId sessionId, int typeId, byte[] object_buffer, JArray attributes, bool isAutoExpandable, string objectId, bool isOwn, CancellationToken token)
{
JArray ret = new JArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ await EvaluateOnCallFrameAndCheck(id,
});

[Fact]
public async Task EvaluateStaticClassField() => await CheckInspectLocalsAtBreakpointSite(
public async Task EvaluateStaticClass() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
Expand All @@ -598,6 +598,27 @@ public async Task EvaluateStaticClassField() => await CheckInspectLocalsAtBreakp

await EvaluateOnCallFrameAndCheck(id,
("DebuggerTests.EvaluateStaticClass.StaticField1", TNumber(10)));
await EvaluateOnCallFrameAndCheck(id,
("DebuggerTests.EvaluateStaticClass.StaticProperty1", TString("StaticProperty1")));
await EvaluateOnCallFrameAndCheck(id,
("DebuggerTests.EvaluateStaticClass.StaticPropertyWithError", TString("System.Exception: not implemented")));
});

[Fact]
public async Task EvaluateStaticClassInvalidField() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

var frame = pause_location["callFrames"][0];

var (_, res) = await EvaluateOnCallFrame(id, "DebuggerTests.EvaluateStaticClass.StaticProperty2", expect_ok: false);
AssertEqual("Failed to resolve member access for DebuggerTests.EvaluateStaticClass.StaticProperty2", res.Error["result"]?["description"]?.Value<string>(), "wrong error message");

(_, res) = await EvaluateOnCallFrame(id, "DebuggerTests.InvalidEvaluateStaticClass.StaticProperty2", expect_ok: false);
AssertEqual("Failed to resolve member access for DebuggerTests.InvalidEvaluateStaticClass.StaticProperty2", res.Error["result"]?["description"]?.Value<string>(), "wrong error message");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ public static class EvaluateStaticClass
{
public static int StaticField1 = 10;
public static string StaticProperty1 => "StaticProperty1";
public static string StaticPropertyWithError => throw new Exception("not implemented");
}

}