Skip to content
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
24 changes: 21 additions & 3 deletions src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4473,13 +4473,31 @@ TADDR MethodAndStartAddressToEECodeInfoPointer(MethodDesc *pMethodDesc, PCODE pN
} CONTRACTL_END;

// MethodDesc ==> Code Address ==>JitManager
TADDR start = pNativeCodeStartAddress ? pNativeCodeStartAddress : pMethodDesc->GetNativeCode();
if(start == 0) {
TADDR entryPoint = pNativeCodeStartAddress ? pNativeCodeStartAddress : pMethodDesc->GetNativeCode();
if(entryPoint == 0) {
// this method hasn't been jitted
return 0;
}

return GetInterpreterCodeFromEntryPointIfPresent(start);
TADDR start = GetInterpreterCodeFromEntryPointIfPresent(entryPoint);

#if defined(TARGET_WASM) && defined(FEATURE_PORTABLE_ENTRYPOINTS)
if (start == entryPoint && entryPoint == pMethodDesc->GetPortableEntryPointIfExists() &&
PortableEntryPoint::HasNativeEntryPoint((PCODE)entryPoint))
{
// Native R2R portable entry points store a function-table index rather than an address
// registered with ExecutionManager. EventPipe needs the corresponding synthetic virtual IP.
DWORD functionTableIndex =
static_cast<DWORD>(reinterpret_cast<TADDR>(PortableEntryPoint::GetActualCode((PCODE)entryPoint)));
TADDR virtualIP = ExecutionManager::GetWasmVirtualIPFromFunctionTableIndex(functionTableIndex);
if (virtualIP != 0)
{
start = virtualIP;
}
}
#endif // TARGET_WASM && FEATURE_PORTABLE_ENTRYPOINTS

return start;
}

/****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public EventPipeDiagnosticsTests(ITestOutputHelper output, SharedBuildPerTestCla
[Theory]
[InlineData(Configuration.Debug, false)]
[InlineData(Configuration.Release, false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/132410", typeof(BuildTestBase), nameof(IsCoreClrRuntime))]
public async Task BlazorEventPipeTestWithCpuSamples(Configuration config, bool aot)
{
string extraProperties = @"
Expand Down Expand Up @@ -76,20 +75,27 @@ await RunForBuildWithDotnetRun(new BlazorRunOptions(
}
));

var methodFound = false;
bool appMethodFound = false;
bool readyToRunMethodFound = false;
using (var source = TraceLog.OpenOrConvert(ConvertTrace(info, "cpuprofile.nettrace")))
{
methodFound = source.CallStacks.Any(stack => stack.CodeAddress.FullMethodName == "BlazorBasicTestApp.Pages.Counter.IncrementCount()");
if (!methodFound)
appMethodFound = source.CallStacks.Any(stack => stack.CodeAddress.FullMethodName == "BlazorBasicTestApp.Pages.Counter.IncrementCount()");
if (!appMethodFound)
{
foreach (var stack in source.CallStacks)
{
_testOutput.WriteLine($"Stack: {stack.CodeAddress.FullMethodName}");
}
}

readyToRunMethodFound = source.CodeAddresses.Any(address => address.FullMethodName.StartsWith("System.Buffer.Memmove(", StringComparison.Ordinal));
}

Assert.True(methodFound, "The cpuprofile.nettrace should contain stack frames for the 'Counter.IncrementCount' method");
Assert.True(appMethodFound, "The cpuprofile.nettrace should contain stack frames for the 'Counter.IncrementCount' method");
if (BuildTestBase.IsCoreClrRuntime)
{
Assert.True(readyToRunMethodFound, "The cpuprofile.nettrace should contain rundown information for the ReadyToRun 'System.Buffer.Memmove' method");
}
}

[Fact]
Expand Down
Loading