Fix testing on arm64. (#1608)
authorMike McLaughlin <mikem@microsoft.com>
Fri, 25 Sep 2020 20:01:17 +0000 (13:01 -0700)
committerGitHub <noreply@github.com>
Fri, 25 Sep 2020 20:01:17 +0000 (13:01 -0700)
Disabled installing and running on 2.1.x when arm/arm64.

Fix the test scripts for arm64 registers.

Upgraded to testing on 3.1.8 and 2.1.23.

Add IMachine::SetContextFlags() and IMachine::GetFullContextFlags() to better support
cross-architecture/cross-OS. Had to use a hard coded context flags for each architecture
because the normal DT_CONTEXT_FULL define only exists for the currently building arch.

The main reason `clrstack -i -a` was failing because the architecture bits in the context
flags were being passed into the DAC/DBI were wrong so the context wasn't being copied.

DAC/DBI context copy helper function that is very sensitive to the dst/src context flags
(at the architecture specific bit) matching.

```
void CORDbgCopyThreadContext(DT_CONTEXT* pDst, const DT_CONTEXT* pSrc)
{
    DWORD dstFlags = pDst->ContextFlags;
    DWORD srcFlags = pSrc->ContextFlags;
    LOG((LF_CORDB, LL_INFO1000000,
         "CP::CTC: pDst=0x%08x dstFlags=0x%x, pSrc=0x%08x srcFlags=0x%x\n",
         pDst, dstFlags, pSrc, srcFlags));

    if ((dstFlags & srcFlags & DT_CONTEXT_CONTROL) == DT_CONTEXT_CONTROL)
    {
        CopyContextChunk(&(pDst->Fp), &(pSrc->Fp), &(pDst->V),
                         DT_CONTEXT_CONTROL);
        CopyContextChunk(&(pDst->Cpsr), &(pSrc->Cpsr), &(pDst->X),
                         DT_CONTEXT_CONTROL);
    }

    if ((dstFlags & srcFlags & DT_CONTEXT_INTEGER) == DT_CONTEXT_INTEGER)
        CopyContextChunk(&(pDst->X[0]), &(pSrc->X[0]), &(pDst->Fp),
                         DT_CONTEXT_INTEGER);
```

Remove arm32/arm64 installs from global because they don't work on MacOS

18 files changed:
eng/InstallRuntimes.proj
eng/Versions.props
src/Microsoft.Diagnostics.DebugServices/ThreadService.cs
src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt
src/SOS/SOS.UnitTests/Scripts/DivZero.script
src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script
src/SOS/SOS.UnitTests/Scripts/StackTests.script
src/SOS/SOS.UnitTests/Scripts/WebApp.script
src/SOS/Strike/ExpressionNode.cpp
src/SOS/Strike/cordebugdatatarget.h
src/SOS/Strike/datatarget.cpp
src/SOS/Strike/disasm.h
src/SOS/Strike/disasmARM.cpp
src/SOS/Strike/disasmX86.cpp
src/SOS/Strike/exts.h
src/SOS/Strike/strike.cpp
src/SOS/Strike/util.cpp
src/inc/dbgtargetcontext.h

index 33cc884e7a87b5ade4adb10e0037f2786b5e97c5..1f84af3d5d17c2f532fac78c0b0a4867174a3c4b 100644 (file)
@@ -72,7 +72,7 @@
   <ItemGroup Condition="!$(InternalReleaseTesting) and !$(PrivateBuildTesting)">
     <TestVersions Include="Latest" RuntimeVersion="$(MicrosoftNETCoreAppVersion)" AspNetVersion="$(MicrosoftAspNetCoreAppRefVersion)" />
     <TestVersions Include="31" RuntimeVersion="$(MicrosoftNETCoreApp31Version)" AspNetVersion="$(MicrosoftAspNetCoreApp31Version)" />
-    <TestVersions Include="21" RuntimeVersion="$(MicrosoftNETCoreApp21Version)" AspNetVersion="$(MicrosoftAspNetCoreApp21Version)" />
+    <TestVersions Condition="'$(BuildArch)' != 'arm' and '$(BuildArch)' != 'arm64'" Include="21" RuntimeVersion="$(MicrosoftNETCoreApp21Version)" AspNetVersion="$(MicrosoftAspNetCoreApp21Version)" />
   </ItemGroup>
 
   <!-- Local private build testing -->
index 13602247098129038203e8f87e9b442f2f966545..e2e76aa8ff44c0ab1daead0d3c753636aafb7379 100644 (file)
@@ -10,9 +10,9 @@
     <!-- Latest symstore version updated by darc -->
     <MicrosoftSymbolStoreVersion>1.0.143102</MicrosoftSymbolStoreVersion>
     <!-- Runtime versions to test -->
-    <MicrosoftNETCoreApp21Version>2.1.18</MicrosoftNETCoreApp21Version>
+    <MicrosoftNETCoreApp21Version>2.1.22</MicrosoftNETCoreApp21Version>
     <MicrosoftAspNetCoreApp21Version>$(MicrosoftNETCoreApp21Version)</MicrosoftAspNetCoreApp21Version>
-    <MicrosoftNETCoreApp31Version>3.1.5</MicrosoftNETCoreApp31Version>
+    <MicrosoftNETCoreApp31Version>3.1.8</MicrosoftNETCoreApp31Version>
     <MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version>
     <!-- Latest shared runtime version updated by darc -->
     <MicrosoftNETCoreAppVersion>5.0.0-rc.2.20474.8</MicrosoftNETCoreAppVersion>
index 97564bd4b17782c1b21e43cf71378cbfc280b77f..a21aaa899350607acb4431a3eba3fd6d5039db10 100644 (file)
@@ -42,25 +42,25 @@ namespace Microsoft.Diagnostics.DebugServices
                 case Architecture.Amd64:
                     // Dumps generated with newer dbgeng have bigger context buffers and clrmd requires the context size to at least be that size.
                     _contextSize = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 0x700 : AMD64Context.Size;
-                    _contextFlags = AMD64Context.ContextControl | AMD64Context.ContextInteger | AMD64Context.ContextSegments;
+                    _contextFlags = AMD64Context.ContextControl | AMD64Context.ContextInteger | AMD64Context.ContextSegments | AMD64Context.ContextFloatingPoint;
                     contextType = typeof(AMD64Context);
                     break;
 
                 case Architecture.X86:
                     _contextSize = X86Context.Size;
-                    _contextFlags = X86Context.ContextControl | X86Context.ContextInteger | X86Context.ContextSegments;
+                    _contextFlags = X86Context.ContextControl | X86Context.ContextInteger | X86Context.ContextSegments | X86Context.ContextFloatingPoint;
                     contextType = typeof(X86Context);
                     break;
 
                 case Architecture.Arm64:
                     _contextSize = Arm64Context.Size;
-                    _contextFlags = Arm64Context.ContextControl | Arm64Context.ContextInteger;
+                    _contextFlags = Arm64Context.ContextControl | Arm64Context.ContextInteger | Arm64Context.ContextFloatingPoint;
                     contextType = typeof(Arm64Context);
                     break;
 
                 case Architecture.Arm:
                     _contextSize = ArmContext.Size;
-                    _contextFlags = ArmContext.ContextControl | ArmContext.ContextInteger;
+                    _contextFlags = ArmContext.ContextControl | ArmContext.ContextInteger | ArmContext.ContextFloatingPoint;
                     contextType = typeof(ArmContext);
                     break;
 
index d5e5ec11cbbd119aca6e9604b1633d1e94b224d3..e32325504275932e6d1357f165734ab7f68adb7a 100644 (file)
   <TestWebApp3>true</TestWebApp3>
   <TestWebApp3 Condition="'$(InternalReleaseTesting)' == 'true'">false</TestWebApp3>
 
+  <TestRuntime21>true</TestRuntime21>
+  <TestRuntime21 Condition="'$(TestLatestOnly)' == 'true'">false</TestRuntime21>
+  <TestRuntime21 Condition="'$(TargetArchitecture)' == 'arm'">false</TestRuntime21>
+  <TestRuntime21 Condition="'$(TargetArchitecture)' == 'arm64'">false</TestRuntime21>
+
   <!-- Build the debuggee for this framework version but run it on latest -->
   <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net5.0</BuildProjectFrameworkLatest>
   <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest>
@@ -56,7 +61,7 @@
       <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
       <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
     </Option>
-    <Option Condition="'$(TestLatestOnly)' != 'true'">
+    <Option Condition="'$(TestRuntime21)' == 'true'">
       <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
       <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
     </Option>
@@ -76,7 +81,7 @@
           <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
           <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
         </Option>
-        <Option Condition="'$(TestLatestOnly)' != 'true'">
+        <Option Condition="'$(TestRuntime21)' == 'true'">
           <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
           <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
         </Option>
index be215a4a99ed13fd17e34d35d2ecaa3a49570e0c..a3df36ecc9962781a0227f2eab19617fed6ff7cd 100644 (file)
@@ -37,7 +37,7 @@ VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?DivZero[\\|/]DivZero\.cs @ 21\s
 VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Dd]iv[Zz]ero.*!C\.F2(\(.*\))?\+0x<HEXVAL>\s+
 VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?DivZero[\\|/]DivZero\.cs @ 33\s*\]\s*
 VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Dd]iv[Zz]ero.*!C\.Main(\(.*\))?\+0x<HEXVAL>\s+
-VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?DivZero[\\|/]DivZero\.cs @ 54\s*\]\s*
+VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?DivZero[\\|/]DivZero\.cs @ (54|53)\s*\]\s*
 
 # Verify that Threads (clrthreads) works
 IFDEF:DOTNETDUMP
@@ -62,4 +62,4 @@ VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
 VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+(\*\*\* WARNING: Unable to verify checksum for DivZero.exe\s*)?C\.DivideByZero(\(.*\))?\s+\[(?i:.*[\\|/]DivZero\.cs) @ 12\s*\]\s+
 VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+C\.F3(\(.*\))?\s+\[(?i:.*[\\|/]DivZero\.cs) @ 21\s*\]\s+
 VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+C\.F2(\(.*\))?\s+\[(?i:.*[\\|/]DivZero\.cs) @ 33\s*\]\s+
-VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+C\.Main(\(.*\))?\s+\[(?i:.*[\\|/]DivZero\.cs) @ 54\s*\]\s+
\ No newline at end of file
+VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+C\.Main(\(.*\))?\s+\[(?i:.*[\\|/]DivZero\.cs) @ (54|53)\s*\]\s+
index 0de4ef7134fa6ee80ec6eb8d102715e44afd2e0a..af42e741e5462d8943f90713ecd01ab4c4b071c0 100644 (file)
@@ -113,7 +113,7 @@ ENDIF:ARM
 IFDEF:ARM64
 VERIFY:\s+x0=<HEXVAL>\s+x1=<HEXVAL>\s+x2=<HEXVAL>\s+
 ENDIF:ARM64
-VERIFY:\s+([r|e]sp|sp)=<HEXVAL>\s+([r|e]bp|lr)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
+VERIFY:\s+([r|e]sp|sp|lr)=<HEXVAL>\s+([r|e]bp|lr|sp)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
 IFDEF:X64
 VERIFY:\s+rax=<HEXVAL>\s+rbx=<HEXVAL>\s+rcx=<HEXVAL>\s+
 ENDIF:X64
@@ -128,7 +128,7 @@ ENDIF:ARM
 IFDEF:ARM64
 VERIFY:\s+x0=<HEXVAL>\s+x1=<HEXVAL>\s+x2=<HEXVAL>\s+
 ENDIF:ARM64
-VERIFY:\s+([r|e]sp|sp)=<HEXVAL>\s+([r|e]bp|lr)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
+VERIFY:\s+([r|e]sp|sp|lr)=<HEXVAL>\s+([r|e]bp|lr|sp)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
 IFDEF:X64
 VERIFY:\s+rax=<HEXVAL>\s+rbx=<HEXVAL>\s+rcx=<HEXVAL>\s+
 ENDIF:X64
@@ -281,4 +281,4 @@ VERIFY:\s+PendingThread:\s+<DECVAL>\s+
 VERIFY:\s+DeadThread:\s+<DECVAL>\s+
 VERIFY:\s+Hosted Runtime:\s+no\s+
 VERIFY:\s+ID\s+OSID\s+ThreadOBJ\s+State.*\s+
-VERIFY:\s+<DECVAL>\s+<DECVAL>\s+<HEXVAL>\s+<HEXVAL>.*\s+
\ No newline at end of file
+VERIFY:\s+<DECVAL>\s+<DECVAL>\s+<HEXVAL>\s+<HEXVAL>.*\s+
index 875877f2738aeae8765f8f725d4f6aa23622d409..eb6634021f2b28f26a1af91eada755cf512cf6bf 100644 (file)
@@ -65,7 +65,7 @@ ENDIF:ARM
 IFDEF:ARM64
 VERIFY:\s+x0=<HEXVAL>\s+x1=<HEXVAL>\s+x2=<HEXVAL>\s+
 ENDIF:ARM64
-VERIFY:\s+([r|e]sp|sp)=<HEXVAL>\s+([r|e]bp|lr)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
+VERIFY:\s+([r|e]sp|sp|lr)=<HEXVAL>\s+([r|e]bp|lr|sp)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
 IFDEF:X64
 VERIFY:\s+rax=<HEXVAL>\s+rbx=<HEXVAL>\s+rcx=<HEXVAL>\s+
 ENDIF:X64
@@ -81,7 +81,7 @@ ENDIF:ARM
 IFDEF:ARM64
 VERIFY:\s+x0=<HEXVAL>\s+x1=<HEXVAL>\s+x2=<HEXVAL>\s+
 ENDIF:ARM64
-VERIFY:\s+([r|e]sp|sp)=<HEXVAL>\s+([r|e]bp|lr)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
+VERIFY:\s+([r|e]sp|sp|lr)=<HEXVAL>\s+([r|e]bp|lr|sp)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
 IFDEF:X64
 VERIFY:\s+rax=<HEXVAL>\s+rbx=<HEXVAL>\s+rcx=<HEXVAL>\s+
 ENDIF:X64
index 5ed1ea937fe784213cd4c2a551bd19cbd322d876..1e235f7fd2e50e44f93e3b11c7b7ce228466dcbe 100644 (file)
@@ -55,7 +55,7 @@ ENDIF:ARM
 IFDEF:ARM64
 VERIFY:\s+x0=<HEXVAL>\s+x1=<HEXVAL>\s+x2=<HEXVAL>\s+
 ENDIF:ARM64
-VERIFY:\s+([r|e]sp|sp)=<HEXVAL>\s+([r|e]bp|lr)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
+VERIFY:\s+([r|e]sp|sp|lr)=<HEXVAL>\s+([r|e]bp|lr|sp)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
 IFDEF:X64
 VERIFY:\s+rax=<HEXVAL>\s+rbx=<HEXVAL>\s+rcx=<HEXVAL>\s+
 ENDIF:X64
@@ -71,7 +71,7 @@ ENDIF:ARM
 IFDEF:ARM64
 VERIFY:\s+x0=<HEXVAL>\s+x1=<HEXVAL>\s+x2=<HEXVAL>\s+
 ENDIF:ARM64
-VERIFY:\s+([r|e]sp|sp)=<HEXVAL>\s+([r|e]bp|lr)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
+VERIFY:\s+([r|e]sp|sp|lr)=<HEXVAL>\s+([r|e]bp|lr|sp)=<HEXVAL>\s+([r|e]ip|pc)=<HEXVAL>\s+
 IFDEF:X64
 VERIFY:\s+rax=<HEXVAL>\s+rbx=<HEXVAL>\s+rcx=<HEXVAL>\s+
 ENDIF:X64
@@ -125,4 +125,4 @@ VERIFY:\s+MT\s+Count\s+TotalSize\s+Class Name\s+
 VERIFY:\s*<HEXVAL>\s+<DECVAL>\s+<DECVAL>\s+.*
 VERIFY:\s*Total\s+<DECVAL>\s+objects\s+
 
-SOSCOMMAND:DumpAsync -mt <PREVOUT> -fields
\ No newline at end of file
+SOSCOMMAND:DumpAsync -mt <PREVOUT> -fields
index 05f88329c8ab32af344c5d9970477fd228863f4b..263fea04aa6a94d2e92d1486ab6cb95431064b8d 100644 (file)
@@ -1797,7 +1797,7 @@ HRESULT ExpressionNode::EnumerateFrames(FrameEnumCallback pCallback, VOID* pUser
         CROSS_PLATFORM_CONTEXT context;
         ULONG32 cbContextActual;
         if ((Status=pStackWalk->GetContext(
-            DT_CONTEXT_FULL
+            g_targetMachine->GetFullContextFlags()
             sizeof(context),
             &cbContextActual,
             (BYTE *)&context))!=S_OK)
index 069c77e7bce8082d421bb33facd13a2aea16c416..71102d465964319cc99e0fb334ee46f7b8b92e91 100644 (file)
@@ -144,16 +144,16 @@ public:
         ULONG32 contextSize,
         BYTE * context)
     {
+        HRESULT hr;
 #ifdef FEATURE_PAL
         if (g_ExtServices == NULL)
         {
             return E_UNEXPECTED;
         }
-        return g_ExtServices->GetThreadContextById(dwThreadOSID, contextFlags, contextSize, context);
+        hr = g_ExtServices->GetThreadContextById(dwThreadOSID, contextFlags, contextSize, context);
 #else
         ULONG ulThreadIDOrig;
         ULONG ulThreadIDRequested;
-        HRESULT hr;
 
         hr = g_ExtSystem->GetCurrentThreadId(&ulThreadIDOrig);
         if (FAILED(hr))
@@ -175,20 +175,20 @@ public:
 
         // Prepare context structure
         ZeroMemory(context, contextSize);
-        ((CONTEXT*)context)->ContextFlags = contextFlags;
+        g_targetMachine->SetContextFlags(context, contextFlags);
 
         // Ok, do it!
         hr = g_ExtAdvanced->GetThreadContext((LPVOID) context, contextSize);
 
-        // GetThreadContext clears ContextFlags but DBI needs it set to know what registers to copy
-        ((CONTEXT*)context)->ContextFlags = contextFlags;
-
         // This is cleanup; failure here doesn't mean GetThreadContext should fail
         // (that's determined by hr).
         g_ExtSystem->SetCurrentThreadId(ulThreadIDOrig);
+#endif // FEATURE_PAL
+
+        // GetThreadContext clears ContextFlags or sets them incorrectly and DBI needs it set to know what registers to copy
+        g_targetMachine->SetContextFlags(context, contextFlags);
 
         return hr;
-#endif // FEATURE_PAL
     }
 
     //
index e75321dcfcb48f0bf6cab7b30c8abef80ccb7b7d..c3b5e6c7d1c23d34bbaa2995807246cda97e5081 100644 (file)
@@ -222,12 +222,13 @@ DataTarget::GetThreadContext(
     /* [in] */ ULONG32 contextSize,
     /* [out, size_is(contextSize)] */ PBYTE context)
 {
+    HRESULT hr;
 #ifdef FEATURE_PAL
     if (g_ExtServices == NULL)
     {
         return E_UNEXPECTED;
     }
-    return g_ExtServices->GetThreadContextById(threadID, contextFlags, contextSize, context);
+    hr = g_ExtServices->GetThreadContextById(threadID, contextFlags, contextSize, context);
 #else
     if (g_ExtSystem == NULL || g_ExtAdvanced == NULL)
     {
@@ -235,7 +236,6 @@ DataTarget::GetThreadContext(
     }
     ULONG ulThreadIDOrig;
     ULONG ulThreadIDRequested;
-    HRESULT hr;
 
     hr = g_ExtSystem->GetCurrentThreadId(&ulThreadIDOrig);
     if (FAILED(hr))
@@ -257,20 +257,20 @@ DataTarget::GetThreadContext(
 
     // Prepare context structure
     ZeroMemory(context, contextSize);
-    ((CONTEXT*) context)->ContextFlags = contextFlags;
+    g_targetMachine->SetContextFlags(context, contextFlags);
 
     // Ok, do it!
     hr = g_ExtAdvanced->GetThreadContext((LPVOID) context, contextSize);
 
-    // GetThreadContext clears ContextFlags
-    ((CONTEXT*)context)->ContextFlags = contextFlags;
-
     // This is cleanup; failure here doesn't mean GetThreadContext should fail
     // (that's determined by hr).
     g_ExtSystem->SetCurrentThreadId(ulThreadIDOrig);
+#endif
+
+    // GetThreadContext clears ContextFlags or sets them incorrectly and DBI needs it set to know what registers to copy
+    g_targetMachine->SetContextFlags(context, contextFlags);
 
     return hr;
-#endif
 }
 
 HRESULT STDMETHODCALLTYPE
index fb2ee3e6400915c319afa2a0f0d736893a90eb0a..d20cd8b2d9003ee19bf5f70c46e0da252b5fae66 100644 (file)
@@ -139,6 +139,9 @@ public:
 
     ULONG GetPlatform()             const { return IMAGE_FILE_MACHINE_I386; }
     ULONG GetContextSize()          const { return sizeof(X86_CONTEXT); }
+    ULONG GetFullContextFlags()     const { return 0x0001000BL; }
+    void SetContextFlags(BYTE* context, ULONG32 contextFlags)   { ((X86_CONTEXT*)context)->ContextFlags = contextFlags; };
+
     virtual void Unassembly(
                 TADDR IPBegin, 
                 TADDR IPEnd, 
@@ -207,6 +210,9 @@ public:
 
     ULONG GetPlatform()             const { return IMAGE_FILE_MACHINE_ARMNT; }
     ULONG GetContextSize()          const { return sizeof(ARM_CONTEXT); }
+    ULONG GetFullContextFlags()     const { return 0x00200007L; }
+    void SetContextFlags(BYTE* context, ULONG32 contextFlags)   { ((ARM_CONTEXT*)context)->ContextFlags = contextFlags; };
+
     virtual void Unassembly(
                 TADDR IPBegin, 
                 TADDR IPEnd, 
@@ -276,6 +282,8 @@ public:
 
     ULONG GetPlatform()             const { return IMAGE_FILE_MACHINE_AMD64; }
     ULONG GetContextSize()          const { return sizeof(AMD64_CONTEXT); }
+    ULONG GetFullContextFlags()     const { return 0x0010000BL; }
+    void SetContextFlags(BYTE* context, ULONG32 contextFlags)   { ((AMD64_CONTEXT*)context)->ContextFlags = contextFlags; };
 
     virtual void Unassembly(
                 TADDR IPBegin, 
@@ -346,6 +354,9 @@ public:
 
     ULONG GetPlatform()             const { return IMAGE_FILE_MACHINE_ARM64; }
     ULONG GetContextSize()          const { return sizeof(ARM64_CONTEXT); }
+    ULONG GetFullContextFlags()     const { return 0x00400007L; }
+    void SetContextFlags(BYTE* context, ULONG32 contextFlags)   { ((ARM64_CONTEXT*)context)->ContextFlags = contextFlags; };
+
     virtual void Unassembly(
                 TADDR IPBegin, 
                 TADDR IPEnd, 
index 86e40e5a4633de464ca8615e7e03ad0f2270b2c3..4e9ce4f22098b83fd72dbc24ac87dbafb3ddbebb 100644 (file)
@@ -595,7 +595,7 @@ BOOL ARMMachine::GetExceptionContext (TADDR stack, TADDR PC, TADDR *cxrAddr, CRO
         return FALSE;
     *cxrAddr = stack;
 
-    if (FAILED (g_ExtData->ReadVirtual(TO_CDADDR(stack), cxr, sizeof(DT_CONTEXT), NULL))) {
+    if (FAILED (g_ExtData->ReadVirtual(TO_CDADDR(stack), cxr, GetContextSize(), NULL))) {
         return FALSE;
     }
 
index d2b1fda8d3e6107f53479a74ff0db35921382735..aad3dd56ef694bde95d087afe7e769554ae072b2 100644 (file)
@@ -392,8 +392,7 @@ void HandleCall(TADDR callee, Register *reg)
     // A jump thunk?
 
     CONTEXT ctx = {0};
-
-    ctx.ContextFlags = (CONTEXT_AMD64 | CONTEXT_CONTROL | CONTEXT_INTEGER);
+    ctx.ContextFlags = (DT_CONTEXT_AMD64 | DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER);
 
     for (unsigned ireg = 0; ireg < 16; ireg++)
     {
@@ -826,7 +825,7 @@ eTargetType GetFinalTarget(TADDR callee, TADDR* finalMDorIP)
     // A jump thunk?
 
     CONTEXT ctx = {0};
-    ctx.ContextFlags = (CONTEXT_AMD64 | CONTEXT_CONTROL | CONTEXT_INTEGER);
+    ctx.ContextFlags = (DT_CONTEXT_AMD64 | DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER);
     ctx.Rip = callee;
 
     CLRDATA_ADDRESS ip = 0, md = 0;
@@ -930,11 +929,10 @@ BOOL
 #ifndef FEATURE_PAL
 #ifdef SOS_TARGET_X86
     X86_CONTEXT * cxr = &pcxr->X86Context;
-    size_t contextSize = offsetof(CONTEXT, ExtendedRegisters);
 #elif defined(SOS_TARGET_AMD64)
     AMD64_CONTEXT * cxr = &pcxr->Amd64Context;
-    size_t contextSize = offsetof(CONTEXT, FltSave);
 #endif
+    size_t contextSize = GetContextSize();
 
     static TADDR IPRetAddr[4] = {0, 0, 0, 0};
 
index 167a0b0fb6b5060b85baa920e42574737d648a50..b6732857c275e9796e3f13052f18b570d87c554b 100644 (file)
@@ -349,9 +349,16 @@ class IMachine
 public:
     // Returns the IMAGE_FILE_MACHINE_*** constant corresponding to the target machine
     virtual ULONG GetPlatform() const = 0;
+
     // Returns the size of the CONTEXT for the target machine
     virtual ULONG GetContextSize() const = 0;
 
+    // Returns the architecture's DT_CONTEXT_FULL flags 
+    virtual ULONG GetFullContextFlags() const = 0;
+
+    // Sets the context flags in the context
+    virtual void SetContextFlags(BYTE* context, ULONG32 contextFlags) = 0;
+
     // Disassembles a managed method specified by the IPBegin-IPEnd range
     virtual void Unassembly(
                 TADDR IPBegin, 
index 4311ea900bb6c884150612d84ef8c56931290e16..c82df2f18d0c3c03a8987b4dfa8997996e56d2c9 100644 (file)
@@ -331,22 +331,13 @@ DECLARE_API(IP2MD)
 // (MAX_STACK_FRAMES is also used by x86 to prevent infinite loops in _EFN_StackTrace)
 #define MAX_STACK_FRAMES 1000
 
-#if defined(_TARGET_WIN64_)
-#define DEBUG_STACK_CONTEXT AMD64_CONTEXT
-#elif defined(_TARGET_ARM_) // _TARGET_WIN64_
-#define DEBUG_STACK_CONTEXT ARM_CONTEXT
-#elif defined(_TARGET_X86_) // _TARGET_ARM_
-#define DEBUG_STACK_CONTEXT X86_CONTEXT
-#endif // _TARGET_X86_
-
-#ifdef DEBUG_STACK_CONTEXT
 // I use a global set of frames for stack walking on win64 because the debugger's
 // GetStackTrace function doesn't provide a way to find out the total size of a stackwalk,
 // and I'd like to have a reasonably big maximum without overflowing the stack by declaring
 // the buffer locally and I also want to get a managed trace in a low memory environment
 // (so no dynamic allocation if possible).
 DEBUG_STACK_FRAME g_Frames[MAX_STACK_FRAMES];
-DEBUG_STACK_CONTEXT g_FrameContexts[MAX_STACK_FRAMES];
+CROSS_PLATFORM_CONTEXT g_FrameContexts[MAX_STACK_FRAMES];
 
 static HRESULT
 GetContextStackTrace(ULONG osThreadId, PULONG pnumFrames)
@@ -386,8 +377,6 @@ GetContextStackTrace(ULONG osThreadId, PULONG pnumFrames)
     return hr;
 }
 
-#endif // DEBUG_STACK_CONTEXT
-
 /**********************************************************************\
 * Routine Description:                                                 *
 *                                                                      *
@@ -13446,7 +13435,7 @@ public:
             ArrayHolder<CROSS_PLATFORM_CONTEXT> context = new CROSS_PLATFORM_CONTEXT[1];
             ULONG32 cbContextActual;
             if ((Status = pStackWalk->GetContext(
-                DT_CONTEXT_FULL,
+                g_targetMachine->GetFullContextFlags(),
                 sizeof(CROSS_PLATFORM_CONTEXT),
                 &cbContextActual,
                 (BYTE *)context.GetPtr())) != S_OK)
@@ -13669,7 +13658,6 @@ public:
             return;
         }
 
-#ifdef DEBUG_STACK_CONTEXT
         PDEBUG_STACK_FRAME currentNativeFrame = NULL;
         ULONG numNativeFrames = 0;
         if (bFull)
@@ -13682,7 +13670,6 @@ public:
             }
             currentNativeFrame = &g_Frames[0];
         }
-#endif // DEBUG_STACK_CONTEXT
 
         unsigned int refCount = 0, errCount = 0;
         ArrayHolder<SOSStackRefData> pRefs = NULL;
@@ -13711,7 +13698,6 @@ public:
                 if (SUCCEEDED(frameDataResult) && FrameData.frameAddr)
                     sp = FrameData.frameAddr;
 
-#ifdef DEBUG_STACK_CONTEXT
                 while ((numNativeFrames > 0) && (currentNativeFrame->StackOffset <= sp))
                 {
                     if (currentNativeFrame->StackOffset != sp)
@@ -13721,7 +13707,6 @@ public:
                     currentNativeFrame++;
                     numNativeFrames--;
                 }
-#endif // DEBUG_STACK_CONTEXT
 
                 // Print the stack pointer.
                 out.WriteColumn(0, sp);
@@ -13805,19 +13790,19 @@ public:
             }
 #endif // FEATURE_PAL
         }
-#ifdef DEBUG_STACK_CONTEXT
+
         while (numNativeFrames > 0)
         {
             PrintNativeStackFrame(out, currentNativeFrame, bSuppressLines);
             currentNativeFrame++;
             numNativeFrames--;
         }
-#endif // DEBUG_STACK_CONTEXT
     }
+
     static HRESULT PrintManagedFrameContext(IXCLRDataStackWalk *pStackWalk)
     {
         CROSS_PLATFORM_CONTEXT context;
-        HRESULT hr = pStackWalk->GetContext(DT_CONTEXT_FULL, g_targetMachine->GetContextSize(), NULL, (BYTE*)&context);
+        HRESULT hr = pStackWalk->GetContext(g_targetMachine->GetFullContextFlags(), g_targetMachine->GetContextSize(), NULL, (BYTE*)&context);
         if (FAILED(hr))
         {
             ExtOut("GetFrameContext failed: %lx\n", hr);
@@ -13899,7 +13884,7 @@ public:
     static HRESULT GetFrameLocation(IXCLRDataStackWalk *pStackWalk, CLRDATA_ADDRESS *ip, CLRDATA_ADDRESS *sp)
     {
         CROSS_PLATFORM_CONTEXT context;
-        HRESULT hr = pStackWalk->GetContext(DT_CONTEXT_FULL, g_targetMachine->GetContextSize(), NULL, (BYTE *)&context);
+        HRESULT hr = pStackWalk->GetContext(g_targetMachine->GetFullContextFlags(), g_targetMachine->GetContextSize(), NULL, (BYTE *)&context);
         if (FAILED(hr))
         {
             ExtOut("GetFrameContext failed: %lx\n", hr);
@@ -15093,8 +15078,7 @@ Exit:
         }
 
         CROSS_PLATFORM_CONTEXT context;
-        if ((Status=pStackWalk->GetContext(DT_CONTEXT_FULL, g_targetMachine->GetContextSize(),
-                                           NULL, (BYTE *)&context))!=S_OK)
+        if ((Status=pStackWalk->GetContext(g_targetMachine->GetFullContextFlags(), g_targetMachine->GetContextSize(), NULL, (BYTE *)&context)) != S_OK)
         {
             goto Exit;
         }
index 7ebf9455fcd651ef8624947a5e1eaf60f4c9cfa7..bc88f3b4f868cc06e90b7011defab6afb9c2038a 100644 (file)
@@ -4054,8 +4054,10 @@ BOOL GetGcStructuresValid()
     // We don't want to use the cached HeapData, because this can change
     // each time the program runs for a while.
     DacpGcHeapData heapData;
-    if (heapData.Request(g_sos) != S_OK)
+    HRESULT hr;
+    if ((hr = heapData.Request(g_sos)) != S_OK)
     {
+        ExtOut("GetGcStructuresValid: request heap data FAILED %08x\n", hr);
         return FALSE;
     }
 
index 93da947a335f1e340aee84873a6b5673a6b820d5..9e830f09f7379af5c049f18cef02d566e445d713 100644 (file)
 // ByteSwapContext.
 //
 
-// For now, the only cross-platform CONTEXTs we support are x86/PAL and ARM/Win. Look in
-// rotor/pal/inc/rotor_pal.h for the original PAL definitions.
-
 //
-// **** NOTE: Keep these in sync with rotor/pal/inc/rotor_pal.h ****
+// **** NOTE: Keep these in sync with pal/inc/pal.h ****
 //
 
 // This odd define pattern is needed because in DBI we set _TARGET_ to match the host and