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

[release/6.0] [wasm][debugger] View object attributes - DebugType=full #62543

Merged
merged 1 commit into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 10 additions & 3 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,19 @@ public unsafe AssemblyInfo(string url, byte[] assembly, byte[] pdb)
asmStream = new MemoryStream(assembly);
peReader = new PEReader(asmStream);
asmMetadataReader = PEReaderExtensions.GetMetadataReader(peReader);
Name = asmMetadataReader.GetAssemblyDefinition().GetAssemblyName().Name + ".dll";
AssemblyNameUnqualified = Name;
if (pdb != null)
{
pdbStream = new MemoryStream(pdb);
pdbMetadataReader = MetadataReaderProvider.FromPortablePdbStream(pdbStream).GetMetadataReader();
try
{
pdbMetadataReader = MetadataReaderProvider.FromPortablePdbStream(pdbStream).GetMetadataReader();
}
catch (BadImageFormatException)
{
Console.WriteLine($"Warning: Unable to read debug information of: {Name} (use DebugType=Portable/Embedded)");
}
}
else
{
Expand All @@ -538,8 +547,6 @@ public unsafe AssemblyInfo(string url, byte[] assembly, byte[] pdb)
pdbMetadataReader = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdbEntry).GetMetadataReader();
}
}
Name = asmMetadataReader.GetAssemblyDefinition().GetAssemblyName().Name + ".dll";
AssemblyNameUnqualified = asmMetadataReader.GetAssemblyDefinition().GetAssemblyName().Name + ".dll";
Populate();
}

Expand Down
28 changes: 28 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,34 @@ await EvaluateAndCheck(
);
}

[Fact]
public async Task InspectLocalsUsingClassFromLibraryUsingDebugTypeFull()
{
byte[] bytes = File.ReadAllBytes(Path.Combine(DebuggerTestAppPath, "debugger-test-with-full-debug-type.dll"));
string asm_base64 = Convert.ToBase64String(bytes);

string pdb_base64 = null;
bytes = File.ReadAllBytes(Path.Combine(DebuggerTestAppPath, "debugger-test-with-full-debug-type.pdb"));
pdb_base64 = Convert.ToBase64String(bytes);

var expression = $"{{ let asm_b64 = '{asm_base64}'; let pdb_b64 = '{pdb_base64}'; invoke_static_method('[debugger-test] DebugTypeFull:CallToEvaluateLocal', asm_b64, pdb_b64); }}";

await EvaluateAndCheck(
"window.setTimeout(function() {" + expression + "; }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs", 818, 8,
"CallToEvaluateLocal",
wait_for_event_fn: async (pause_location) =>
{
var a_props = await GetObjectOnFrame(pause_location["callFrames"][0], "a");
await CheckProps(a_props, new
{
a = TNumber(10),
b = TNumber(20),
c = TNumber(30)
}, "a");
}
);
}
//TODO add tests covering basic stepping behavior as step in/out/over
}
}
12 changes: 12 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -807,3 +807,15 @@ public int Increment(int count)
return count + 1;
}
}

public class DebugTypeFull
{
public static void CallToEvaluateLocal(string asm_base64, string pdb_base64)
{
var asm = System.Reflection.Assembly.LoadFrom("debugger-test-with-full-debug-type.dll");
var myType = asm.GetType("DebuggerTests.ClassToInspectWithDebugTypeFull");
var myMethod = myType.GetConstructor(new Type[] { });
var a = myMethod.Invoke(new object[]{});
System.Diagnostics.Debugger.Break();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
<ProjectReference Include="..\library-dependency-debugger-test2\library-dependency-debugger-test2.csproj" Private="true"/>
<ProjectReference Include="..\debugger-test-with-source-link\debugger-test-with-source-link.csproj" Private="true"/>
<ProjectReference Include="..\ApplyUpdateReferencedAssembly\ApplyUpdateReferencedAssembly.csproj" />
<ProjectReference Include="..\debugger-test-with-full-debug-type\debugger-test-with-full-debug-type.csproj" Private="true"/>
</ItemGroup>

<Target Name="PrepareForWasmBuildApp" DependsOnTargets="RebuildWasmAppBuilder;Build">
<PropertyGroup>
<EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
<WasmAppDir>$(AppDir)</WasmAppDir>
<WasmMainJSPath>$(MonoProjectRoot)wasm\runtime-test.js</WasmMainJSPath>
<!-- like is used on blazor -->
Expand All @@ -37,6 +39,7 @@
<ItemGroup>
<WasmAssembliesToBundle Include="$(OutDir)\$(TargetFileName)" />
<WasmAssembliesToBundle Include="$(OutDir)\debugger-test-with-source-link.dll" />
<WasmAssembliesToBundle Include="$(OutDir)\debugger-test-with-full-debug-type.dll" />
<WasmAssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native"/>
<WasmAssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidDir)lib\$(NetCoreAppCurrent)"/>

Expand Down