summaryrefslogtreecommitdiff
path: root/tests/src/baseservices
diff options
context:
space:
mode:
authorKoundinya Veluri <kouvel@users.noreply.github.com>2018-02-11 16:57:09 -0800
committerNoah Falk <noahfalk@users.noreply.github.com>2018-02-11 16:57:08 -0800
commitce060415550334e598ee2efbc4beed0f07ede3f9 (patch)
tree47e868f8019cf55ef537a5508503fb971f960278 /tests/src/baseservices
parent78cd08538b59e8c2cff032f39a919b00eb552d74 (diff)
downloadcoreclr-ce060415550334e598ee2efbc4beed0f07ede3f9.tar.gz
coreclr-ce060415550334e598ee2efbc4beed0f07ede3f9.tar.bz2
coreclr-ce060415550334e598ee2efbc4beed0f07ede3f9.zip
Fix stack trace population to get proper source/line info for tier 1 methods (#16302)
Fixes https://github.com/dotnet/coreclr/issues/16224
Diffstat (limited to 'tests/src/baseservices')
-rw-r--r--tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.cs58
-rw-r--r--tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.csproj33
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.cs b/tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.cs
new file mode 100644
index 0000000000..e5eba333ee
--- /dev/null
+++ b/tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.cs
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading;
+
+internal static class Program
+{
+ private static int Main()
+ {
+ const int Pass = 100, Fail = 1;
+
+ string tier0StackTrace = Capture(true);
+ PromoteToTier1(() => Capture(false));
+ string tier1StackTrace = Capture(true);
+ return tier0StackTrace == tier1StackTrace ? Pass : Fail;
+ }
+
+ private static void PromoteToTier1(Action action)
+ {
+ // Call the method once to register a call for call counting
+ action();
+
+ // Allow time for call counting to begin
+ Thread.Sleep(500);
+
+ // Call the method enough times to trigger tier 1 promotion
+ for (int i = 0; i < 100; i++)
+ {
+ action();
+ }
+
+ // Allow time for the method to be jitted at tier 1
+ Thread.Sleep(500);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static string Capture(bool doWork)
+ {
+ if (!doWork)
+ {
+ return null;
+ }
+
+ string stackTrace = new StackTrace(true).ToString().Trim();
+
+ // Remove the last line of the stack trace, which would correspond with Main()
+ int lastNewLineIndex = stackTrace.LastIndexOf('\n');
+ if (lastNewLineIndex == -1)
+ {
+ return null;
+ }
+ return stackTrace.Substring(0, lastNewLineIndex).Trim();
+ }
+}
diff --git a/tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.csproj b/tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.csproj
new file mode 100644
index 0000000000..c426338ea9
--- /dev/null
+++ b/tests/src/baseservices/exceptions/stacktrace/Tier1StackTrace.csproj
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{8758BFAC-7D36-4244-8A36-4C464C0AFA6D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <LangVersion>latest</LangVersion>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Optimize>true</Optimize>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Tier1StackTrace.cs" />
+ </ItemGroup>
+ <PropertyGroup>
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_EXPERIMENTAL_TieredCompilation=1
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_EXPERIMENTAL_TieredCompilation=1
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>