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
8 changes: 8 additions & 0 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7045,6 +7045,14 @@ CLRDataCreateInstance(REFIID iid,
// Release the AddRef from the QI.
pClrDataAccess->Release();
}

if (cdacInterface == nullptr)
{
// If we requested to use the cDAC, but failed to create the cDAC interface, return failure
// Release the ClrDataAccess instance we created
pClrDataAccess->Release();
return E_FAIL;
}
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/externals.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\corerun*" Condition="'$(TargetsAndroid)' != 'true'" />
<!-- Include cDAC reader library
TODO: [cdac] Remove once cdacreader is added to shipping shared framework -->
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\*cdacreader*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\*cdacreader*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\*mscordaccore_universal*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\*mscordaccore_universal*" />
</ItemGroup>
<!-- If the build has native sanitizers, copy over the non-sanitized diagnostic binaries so they can be loaded by a debugger -->
<ItemGroup Condition="'$(EnableNativeSanitizers)' != ''">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,17 @@ public bool Unwind(ref AMD64Context context)
branchTarget = nextByte - imageBase;
if (ReadByteAt(nextByte) == JMP_IMM8_OP)
{
branchTarget += 2u + ReadByteAt(nextByte + 1);
// sign-extend the 8-bit immediate value
branchTarget += 2u + (ulong)(sbyte)ReadByteAt(nextByte + 1);
}
else
{
// sign-extend the 32-bit immediate value
int delta = ReadByteAt(nextByte + 1) |
(ReadByteAt(nextByte + 2) << 8) |
(ReadByteAt(nextByte + 3) << 16) |
(ReadByteAt(nextByte + 4) << 24);
branchTarget += (uint)(5 + delta);
branchTarget += (ulong)(5 + delta);
}

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum ContextFlagsValues : uint
}

public readonly uint Size => 0x4d0;
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_ALL;

public TargetPointer StackPointer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public enum ContextFlagsValues : uint

public readonly uint Size => 0x390;

public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
public readonly uint DefaultContextFlags => (uint)(ContextFlagsValues.CONTEXT_CONTROL |
ContextFlagsValues.CONTEXT_INTEGER |
ContextFlagsValues.CONTEXT_FLOATING_POINT |
ContextFlagsValues.CONTEXT_DEBUG_REGISTERS);

public TargetPointer StackPointer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public enum ContextFlagsValues : uint
}

public readonly uint Size => 0x1a0;
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_ALL;

public TargetPointer StackPointer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public enum ContextFlagsValues : uint
CONTEXT_SEGMENTS = CONTEXT_i386 | 0x4,
CONTEXT_FLOATING_POINT = CONTEXT_i386 | 0x8,
CONTEXT_DEBUG_REGISTERS = CONTEXT_i386 | 0x10,
CONTEXT_EXTENDED_REGISTERS = CONTEXT_i386 | 0x20,
CONTEXT_FULL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT,
CONTEXT_ALL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS,
CONTEXT_ALL = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS,
CONTEXT_XSTATE = CONTEXT_i386 | 0x40,

//
Expand All @@ -37,7 +38,7 @@ public enum ContextFlagsValues : uint
}

public readonly uint Size => 0x2cc;
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_FULL;
public readonly uint DefaultContextFlags => (uint)ContextFlagsValues.CONTEXT_ALL;

public TargetPointer StackPointer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ private unsafe void FillContextFromThread(IPlatformAgnosticContext context, Thre
{
byte[] bytes = new byte[context.Size];
Span<byte> buffer = new Span<byte>(bytes);
// The underlying ICLRDataTarget.GetThreadContext has some variance depending on the host.
// SOS's managed implementation sets the ContextFlags to platform specific values defined in ThreadService.cs (diagnostics repo)
// SOS's native implementation keeps the ContextFlags passed into this function.
// To match the DAC behavior, the DefaultContextFlags are what the DAC passes in in DacGetThreadContext.
// In most implementations, this will be overridden by the host, but in some cases, it may not be.
if (!_target.TryGetThreadContext(threadData.OSId.Value, context.DefaultContextFlags, buffer))
{
throw new InvalidOperationException($"GetThreadContext failed for thread {threadData.OSId.Value}");
Expand Down
Loading