Skip to content

Commit 676321b

Browse files
committed
Merge branch 'cdac-fail-fast' into enable_FEATURE_STUBPRECODE_DYNAMIC_HELPERS_again
2 parents 71b3876 + ddb0094 commit 676321b

File tree

8 files changed

+28
-9
lines changed

8 files changed

+28
-9
lines changed

src/coreclr/debug/daccess/daccess.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7045,6 +7045,14 @@ CLRDataCreateInstance(REFIID iid,
70457045
// Release the AddRef from the QI.
70467046
pClrDataAccess->Release();
70477047
}
7048+
7049+
if (cdacInterface == nullptr)
7050+
{
7051+
// If we requested to use the cDAC, but failed to create the cDAC interface, return failure
7052+
// Release the ClrDataAccess instance we created
7053+
pClrDataAccess->Release();
7054+
return E_FAIL;
7055+
}
70487056
}
70497057
}
70507058
#endif

src/libraries/externals.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\corerun*" Condition="'$(TargetsAndroid)' != 'true'" />
9191
<!-- Include cDAC reader library
9292
TODO: [cdac] Remove once cdacreader is added to shipping shared framework -->
93-
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\*cdacreader*" />
94-
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\*cdacreader*" />
93+
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\*mscordaccore_universal*" />
94+
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\*mscordaccore_universal*" />
9595
</ItemGroup>
9696
<!-- If the build has native sanitizers, copy over the non-sanitized diagnostic binaries so they can be loaded by a debugger -->
9797
<ItemGroup Condition="'$(EnableNativeSanitizers)' != ''">

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64/AMD64Unwinder.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,17 @@ public bool Unwind(ref AMD64Context context)
303303
branchTarget = nextByte - imageBase;
304304
if (ReadByteAt(nextByte) == JMP_IMM8_OP)
305305
{
306-
branchTarget += 2u + ReadByteAt(nextByte + 1);
306+
// sign-extend the 8-bit immediate value
307+
branchTarget += 2u + (ulong)(sbyte)ReadByteAt(nextByte + 1);
307308
}
308309
else
309310
{
311+
// sign-extend the 32-bit immediate value
310312
int delta = ReadByteAt(nextByte + 1) |
311313
(ReadByteAt(nextByte + 2) << 8) |
312314
(ReadByteAt(nextByte + 3) << 16) |
313315
(ReadByteAt(nextByte + 4) << 24);
314-
branchTarget += (uint)(5 + delta);
316+
branchTarget += (ulong)(5 + delta);
315317
}
316318

317319
//

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64Context.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum ContextFlagsValues : uint
3131
}
3232

3333
public readonly uint Size => 0x4d0;
34-
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
34+
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_ALL;
3535

3636
public TargetPointer StackPointer
3737
{

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/ARM64Context.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public enum ContextFlagsValues : uint
3838

3939
public readonly uint Size => 0x390;
4040

41-
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
41+
public readonly uint DefaultContextFlags => (uint)(ContextFlagsValues.CONTEXT_CONTROL |
42+
ContextFlagsValues.CONTEXT_INTEGER |
43+
ContextFlagsValues.CONTEXT_FLOATING_POINT |
44+
ContextFlagsValues.CONTEXT_DEBUG_REGISTERS);
4245

4346
public TargetPointer StackPointer
4447
{

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/ARMContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public enum ContextFlagsValues : uint
2929
}
3030

3131
public readonly uint Size => 0x1a0;
32-
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
32+
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_ALL;
3333

3434
public TargetPointer StackPointer
3535
{

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86Context.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public enum ContextFlagsValues : uint
2222
CONTEXT_SEGMENTS = CONTEXT_i386 | 0x4,
2323
CONTEXT_FLOATING_POINT = CONTEXT_i386 | 0x8,
2424
CONTEXT_DEBUG_REGISTERS = CONTEXT_i386 | 0x10,
25+
CONTEXT_EXTENDED_REGISTERS = CONTEXT_i386 | 0x20,
2526
CONTEXT_FULL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT,
26-
CONTEXT_ALL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS,
27+
CONTEXT_ALL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS,
2728
CONTEXT_XSTATE = CONTEXT_i386 | 0x40,
2829

2930
//
@@ -37,7 +38,7 @@ public enum ContextFlagsValues : uint
3738
}
3839

3940
public readonly uint Size => 0x2cc;
40-
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
41+
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_ALL;
4142

4243
public TargetPointer StackPointer
4344
{

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ private unsafe void FillContextFromThread(IPlatformAgnosticContext context, Thre
191191
{
192192
byte[] bytes = new byte[context.Size];
193193
Span<byte> buffer = new Span<byte>(bytes);
194+
// The underlying ICLRDataTarget.GetThreadContext has some variance depending on the host.
195+
// SOS's managed implementation sets the ContextFlags to platform specific values defined in ThreadService.cs (diagnostics repo)
196+
// SOS's native implementation keeps the ContextFlags passed into this function.
197+
// To match the DAC behavior, the DefaultContextFlags are what the DAC passes in in DacGetThreadContext.
198+
// In most implementations, this will be overridden by the host, but in some cases, it may not be.
194199
if (!_target.TryGetThreadContext(threadData.OSId.Value, context.DefaultContextFlags, buffer))
195200
{
196201
throw new InvalidOperationException($"GetThreadContext failed for thread {threadData.OSId.Value}");

0 commit comments

Comments
 (0)