Change SOS breaking change from warning to error; better dotnet-dump target errors...
authorMike McLaughlin <mikem@microsoft.com>
Thu, 6 Jun 2024 17:52:48 +0000 (10:52 -0700)
committerGitHub <noreply@github.com>
Thu, 6 Jun 2024 17:52:48 +0000 (10:52 -0700)
* Change DAC breaking change behavior from warning to error.

* Better dotnet-dump analyze error message for cross OS dumps. Don't
allow Linux and Windows dumps when running on MacOS; don't allow OSX and
Windows dumps when running on Linux.

src/SOS/Strike/strike.cpp
src/SOS/Strike/util.cpp
src/Tools/dotnet-dump/Analyzer.cs

index 4dbb74da94d1bb21ba24e3a194cb7e26b334e710..b6f42fef6a68ab623032606077f81843768bc144 100644 (file)
@@ -2892,7 +2892,10 @@ DECLARE_API(PrintException)
         return E_INVALIDARG;
     }
 
-    CheckBreakingRuntimeChange();
+    if (CheckBreakingRuntimeChange())
+    {
+        return E_FAIL;
+    }
 
     if (bLineNumbers)
     {
@@ -4802,8 +4805,10 @@ DECLARE_API(Threads)
 
             if (bSupported)
             {
-                CheckBreakingRuntimeChange();
-
+                if (CheckBreakingRuntimeChange())
+                {
+                    return E_FAIL;
+                }
                 HRESULT Status2 = PrintSpecialThreads();
                 if (!SUCCEEDED(Status2))
                     Status = Status2;
@@ -7451,7 +7456,11 @@ DECLARE_API(DumpLog)
         return E_FAIL;
     }
 
-    CheckBreakingRuntimeChange();
+    if (CheckBreakingRuntimeChange())
+    {
+        return E_FAIL;
+    }
+
     LoadRuntimeSymbols();
 
     const char* fileName = "StressLog.txt";
index c850f74a89318782894b00f460b9606e41198257..63001e1999d7c54a63f2b7336f61a4eaa2cfff81 100644 (file)
@@ -3391,9 +3391,9 @@ bool CheckBreakingRuntimeChange(int* pVersion)
             {
                 if (version > SOS_BREAKING_CHANGE_VERSION)
                 {
-                    ExtWarn("WARNING: SOS needs to be upgraded for this version of the runtime. Some commands may not work correctly.\n");
-                    ExtWarn("For more information see https://go.microsoft.com/fwlink/?linkid=2135652\n");
-                    ExtWarn("\n");
+                    ExtErr("SOS needs to be upgraded for this version of the runtime. Some commands may not work correctly.\n");
+                    ExtErr("For more information see https://go.microsoft.com/fwlink/?linkid=2135652\n");
+                    ExtErr("\n");
                     result = true;
                 }
             }
index 0fa51a64bf0fdee035dc67e2eaf1e2fcd91cd79d..321488433751f13a3d713086e9917f5f0526e4ed 100644 (file)
@@ -115,13 +115,14 @@ namespace Microsoft.Diagnostics.Tools.Dump
             try
             {
                 using DataTarget dataTarget = DataTarget.LoadDump(dump_path.FullName);
-
                 OSPlatform targetPlatform = dataTarget.DataReader.TargetPlatform;
-                if (targetPlatform != OSPlatform.OSX &&
-                    (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ||
-                     dataTarget.DataReader.EnumerateModules().Any((module) => Path.GetExtension(module.FileName) == ".dylib")))
+                if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && (targetPlatform != OSPlatform.OSX))
+                {
+                    throw new NotSupportedException("Analyzing Windows or Linux dumps not supported when running on MacOS");
+                }
+                if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && (targetPlatform != OSPlatform.Linux))
                 {
-                    targetPlatform = OSPlatform.OSX;
+                    throw new NotSupportedException("Analyzing Windows or MacOS dumps not supported when running on Linux");
                 }
                 TargetFromDataReader target = new(dataTarget.DataReader, targetPlatform, this, _targetIdFactory++, dump_path.FullName);
                 contextService.SetCurrentTarget(target);