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
10 changes: 10 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Param(
[switch] $skipnative,
[switch] $bundletools,
[switch] $useCdac,
[switch] $noFallback,
[string] $methodfilter = '',
[string] $classfilter = '',
[ValidatePattern("(default|\d+\.\d+.\d+(-[a-z0-9\.]+)?)")][string] $dotnetruntimeversion = 'default',
Expand All @@ -25,6 +26,11 @@ Param(
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

if ($noFallback -and -not $useCdac) {
Write-Error "-noFallback requires -useCdac to also be specified."
exit 1
}

$crossbuild = $false
if (($architecture -eq "arm") -or ($architecture -eq "arm64")) {
$processor = @([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())
Expand Down Expand Up @@ -101,6 +107,10 @@ if ($test) {
$env:SOS_TEST_CDAC="true"
}

if ($noFallback) {
$env:SOS_TEST_CDAC_NO_FALLBACK="true"
}

# Build the test filter argument if provided
# Use backslash-escaped quotes so they survive the additional quoting in tools.ps1
$testFilterArg = ''
Expand Down
14 changes: 14 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ __Test=0
__TestFilter=
__UnprocessedBuildArgs=
__UseCdac=0
__NoFallback=0
__LiveRuntimeDir=

usage_list+=("-skipmanaged: do not build managed components.")
Expand Down Expand Up @@ -122,6 +123,10 @@ handle_arguments() {
__UseCdac=1
;;

nofallback|-nofallback)
__NoFallback=1
;;

-warnaserror|-nodereuse)
__ManagedBuildArgs="$__ManagedBuildArgs $1 $2"
__ShiftArgs=1
Expand All @@ -135,6 +140,11 @@ handle_arguments() {

source "$__RepoRootDir"/eng/native/build-commons.sh

if [[ "$__NoFallback" == 1 && "$__UseCdac" != 1 ]]; then
echo "-nofallback requires -usecdac to also be specified."
exit 1
fi

__LogsDir="$__RootBinDir/log/$__BuildType"
__ConfigTriplet="$__TargetOS.$__TargetArch.$__BuildType"
__BinDir="$__RootBinDir/bin/$__ConfigTriplet"
Expand Down Expand Up @@ -315,6 +325,10 @@ if [[ "$__Test" == 1 ]]; then
export SOS_TEST_CDAC="true"
fi

if [[ "$__NoFallback" == 1 ]]; then
export SOS_TEST_CDAC_NO_FALLBACK="true"
fi

# Build the test filter argument if provided
__TestFilterArg=
if [[ -n "$__TestFilter" ]]; then
Expand Down
17 changes: 15 additions & 2 deletions src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private void ParseConfigFile(string path)
["TargetRid"] = GetRid(),
["TargetArchitecture"] = OS.TargetArchitecture.ToString().ToLowerInvariant(),
["NuGetPackageCacheDir"] = nugetPackages,
["TestCDAC"] = Environment.GetEnvironmentVariable("SOS_TEST_CDAC")
["TestCDAC"] = Environment.GetEnvironmentVariable("SOS_TEST_CDAC"),
["TestCDACNoFallback"] = Environment.GetEnvironmentVariable("SOS_TEST_CDAC_NO_FALLBACK")
};
if (OS.Kind == OSKind.Windows)
{
Expand Down Expand Up @@ -454,7 +455,11 @@ private string GetStringViewWithVersion(string version)
{
sb.Append(".singlefile");
}
if (TestCDAC)
if (TestCDACNoFallback)
{
sb.Append(".cdac_no_fallback");
}
else if (TestCDAC)
{
sb.Append(".cdac");
}
Expand Down Expand Up @@ -560,6 +565,14 @@ public bool TestCDAC
get { return string.Equals(GetValue("TestCDAC"), "true", StringComparison.InvariantCultureIgnoreCase); }
}

/// <summary>
/// Returns true if tests should use the cDAC with no fallback to the legacy DAC.
/// </summary>
public bool TestCDACNoFallback
{
get { return string.Equals(GetValue("TestCDACNoFallback"), "true", StringComparison.InvariantCultureIgnoreCase); }
}

/// <summary>
/// The test runner script directory
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion src/tests/SOS.UnitTests/SOSRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,12 @@ public static async Task<SOSRunner> StartDebugger(TestInformation information, D
WithLog(scriptLogger).
WithTimeout(TimeSpan.FromMinutes(10));

if (config.TestCDAC)
if (config.TestCDACNoFallback)
{
processRunner.WithEnvironmentVariable("DOTNET_ENABLE_CDAC", "1");
processRunner.WithEnvironmentVariable("CDAC_NO_FALLBACK", "1");
}
else if (config.TestCDAC)
{
processRunner.WithEnvironmentVariable("DOTNET_ENABLE_CDAC", "1");
}
Expand Down Expand Up @@ -1558,6 +1563,10 @@ private HashSet<string> GetEnabledDefines()
{
defines.Add("HOST_RUNTIME_NONE");
}
if (_config.TestCDACNoFallback)
{
defines.Add("CDAC_NO_FALLBACK_TESTING");
}
return defines;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ VERIFY:(?:[^\r\n]*\r?\n){6}[ \t]*\r?\n
!VERIFY:(?:[^\r\n]*\r?\n){8}[ \t]*\r?\n

# Verify that ClrStack with number of frames works using ICorDebug
!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:ClrStack -i -c 1
VERIFY:(?:[^\r\n]*\r?\n){8}[ \t]*\r?\n
!VERIFY:(?:[^\r\n]*\r?\n){10}[ \t]*\r?\n
Expand All @@ -55,3 +56,4 @@ VERIFY:(?:[^\r\n]*\r?\n){10}[ \t]*\r?\n
SOSCOMMAND:ClrStack -i -c 4
VERIFY:(?:[^\r\n]*\r?\n){11}[ \t]*\r?\n
!VERIFY:(?:[^\r\n]*\r?\n){13}[ \t]*\r?\n
ENDIF:CDAC_NO_FALLBACK_TESTING
2 changes: 2 additions & 0 deletions src/tests/SOS.UnitTests/Scripts/DualRuntimes.script
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+

# Verify that ClrStack with the ICorDebug options works
!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:ClrStack -i
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+Stack walk complete.\s+
ENDIF:CDAC_NO_FALLBACK_TESTING

# Verify that Threads (clrthreads) works
IFDEF:DOTNETDUMP
Expand Down
2 changes: 2 additions & 0 deletions src/tests/SOS.UnitTests/Scripts/DynamicMethod.script
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ CONTINUE

LOADSOS

!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:ClrStack -i -a
VERIFY:\s+LOCALS:\s+

SOSCOMMAND:DumpIL <POUT>.*System\.Reflection\.Emit\.DynamicMethod dynamicMethod @ 0x(<HEXVAL>).*\s+<POUT>
VERIFY:\s+IL_0000: ldarg.0\s+
VERIFY:\s+IL_0001: ldc.i4.0\s+
ENDIF:CDAC_NO_FALLBACK_TESTING
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ LOADSOS
SOSCOMMAND:clrstack -l

# stackwalk through ICorDebug with locals
!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:clrstack -i -l
VERIFY:int\s+length\s+=\s+13
ENDIF:CDAC_NO_FALLBACK_TESTING
2 changes: 2 additions & 0 deletions src/tests/SOS.UnitTests/Scripts/StackAndOtherTests.script
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[
IFDEF:NETCORE_OR_DOTNETDUMP

# Verify that ClrStack with the ICorDebug options works
!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:ClrStack -i
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
Expand All @@ -179,6 +180,7 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] I4 SymbolTestApp\.Program\.Foo2\(.
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] I4 SymbolTestApp\.Program\.Foo1\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void SymbolTestApp\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+Stack walk complete.\s+
ENDIF:CDAC_NO_FALLBACK_TESTING

SOSCOMMAND: runtimes

Expand Down
2 changes: 2 additions & 0 deletions src/tests/SOS.UnitTests/Scripts/StackTests.script
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ IFDEF:NETCORE_OR_DOTNETDUMP
!IFDEF:ALPINE

# 5) Verifying that ClrStack with the ICorDebug options works
!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:ClrStack -i
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
Expand All @@ -130,6 +131,7 @@ VERIFY:\s+\+ System.FormatException ex @ 0x<HEXVAL>\s+
ENDIF:SINGLE_FILE_APP
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void NestedExceptionTest\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+Stack walk complete.\s+
ENDIF:CDAC_NO_FALLBACK_TESTING

ENDIF:ALPINE
ENDIF:NETCORE_OR_DOTNETDUMP
Expand Down
2 changes: 2 additions & 0 deletions src/tests/SOS.UnitTests/Scripts/WebApp.script
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ VERIFY:\s+eax=<HEXVAL>\s+ebx=<HEXVAL>\s+ecx=<HEXVAL>\s+
ENDIF:X86

# Verify that ClrStack with the ICorDebug options works
!IFDEF:CDAC_NO_FALLBACK_TESTING
SOSCOMMAND:ClrStack -i
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+Stack walk complete.\s+
ENDIF:CDAC_NO_FALLBACK_TESTING

# Verify that Threads (clrthreads) works
SOSCOMMAND:clrthreads
Expand Down