Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Enable interop debugging for Windows amd64 and x86. (#8603)
Browse files Browse the repository at this point in the history
Found sos portable pdb problem on x86.  Fixed interop problems between the native sos and SOS.NetCore managed helper assembly.
  • Loading branch information
mikem8361 authored Dec 13, 2016
1 parent 1242b3e commit db3994a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
3 changes: 3 additions & 0 deletions clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
endif(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
add_definitions(-DFEATURE_HOST_ASSEMBLY_RESOLVER)
add_definitions(-DFEATURE_ICASTABLE)
if (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386))
add_definitions(-DFEATURE_INTEROP_DEBUGGING)
endif (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386))
if (CLR_CMAKE_PLATFORM_UNIX OR CLR_CMAKE_TARGET_ARCH_ARM64)
add_definitions(-DFEATURE_IMPLICIT_TLS)
set(FEATURE_IMPLICIT_TLS 1)
Expand Down
16 changes: 8 additions & 8 deletions src/ToolBox/SOS/NETCore/SymbolReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal struct MethodDebugInfo
/// Read memory callback
/// </summary>
/// <returns>number of bytes read or 0 for error</returns>
internal unsafe delegate int ReadMemoryDelegate(IntPtr address, byte* buffer, int count);
internal unsafe delegate int ReadMemoryDelegate(ulong address, byte* buffer, int count);

private sealed class OpenedReader : IDisposable
{
Expand All @@ -61,7 +61,7 @@ public OpenedReader(MetadataReaderProvider provider, MetadataReader reader)
/// </summary>
private class TargetStream : Stream
{
readonly IntPtr _address;
readonly ulong _address;
readonly ReadMemoryDelegate _readMemory;

public override long Position { get; set; }
Expand All @@ -70,7 +70,7 @@ private class TargetStream : Stream
public override bool CanRead { get { return true; } }
public override bool CanWrite { get { return false; } }

public TargetStream(IntPtr address, int size, ReadMemoryDelegate readMemory)
public TargetStream(ulong address, int size, ReadMemoryDelegate readMemory)
: base()
{
_address = address;
Expand All @@ -89,7 +89,7 @@ public override int Read(byte[] buffer, int offset, int count)
{
fixed (byte* p = &buffer[offset])
{
int read = _readMemory(new IntPtr(_address.ToInt64() + Position), p, count);
int read = _readMemory(_address + (ulong)Position, p, count);
Position += read;
return read;
}
Expand Down Expand Up @@ -157,18 +157,18 @@ private static string GetFileName(string pathName)
/// <param name="inMemoryPdbAddress">in memory PDB address or zero</param>
/// <param name="inMemoryPdbSize">in memory PDB size</param>
/// <returns>Symbol reader handle or zero if error</returns>
internal static IntPtr LoadSymbolsForModule(string assemblyPath, bool isFileLayout, IntPtr loadedPeAddress, int loadedPeSize,
IntPtr inMemoryPdbAddress, int inMemoryPdbSize, ReadMemoryDelegate readMemory)
internal static IntPtr LoadSymbolsForModule(string assemblyPath, bool isFileLayout, ulong loadedPeAddress, int loadedPeSize,
ulong inMemoryPdbAddress, int inMemoryPdbSize, ReadMemoryDelegate readMemory)
{
try
{
TargetStream peStream = null;
if (assemblyPath == null && loadedPeAddress != IntPtr.Zero)
if (assemblyPath == null && loadedPeAddress != 0)
{
peStream = new TargetStream(loadedPeAddress, loadedPeSize, readMemory);
}
TargetStream pdbStream = null;
if (inMemoryPdbAddress != IntPtr.Zero)
if (inMemoryPdbAddress != 0)
{
pdbStream = new TargetStream(inMemoryPdbAddress, inMemoryPdbSize, readMemory);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/SOS/Strike/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6134,7 +6134,7 @@ HRESULT SymbolReader::LoadSymbolsForWindowsPDB(___in IMetaDataImport* pMD, ___in
int ReadMemoryForSymbols(ULONG64 address, char *buffer, int cb)
{
ULONG read;
if (SafeReadMemory(address, (PVOID)buffer, cb, &read))
if (SafeReadMemory(TO_TADDR(address), (PVOID)buffer, cb, &read))
{
return read;
}
Expand Down
12 changes: 6 additions & 6 deletions src/ToolBox/SOS/Strike/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2355,19 +2355,19 @@ static const char *SymbolReaderDllName = "SOS.NETCore";
static const char *SymbolReaderClassName = "SOS.SymbolReader";

typedef int (*ReadMemoryDelegate)(ULONG64, char *, int);
typedef ULONG64 (*LoadSymbolsForModuleDelegate)(const char*, BOOL, ULONG64, int, ULONG64, int, ReadMemoryDelegate);
typedef void (*DisposeDelegate)(ULONG64);
typedef BOOL (*ResolveSequencePointDelegate)(ULONG64, const char*, unsigned int, unsigned int*, unsigned int*);
typedef BOOL (*GetLocalVariableName)(ULONG64, int, int, BSTR*);
typedef BOOL (*GetLineByILOffsetDelegate)(ULONG64, mdMethodDef, ULONG64, ULONG *, BSTR*);
typedef PVOID (*LoadSymbolsForModuleDelegate)(const char*, BOOL, ULONG64, int, ULONG64, int, ReadMemoryDelegate);
typedef void (*DisposeDelegate)(PVOID);
typedef BOOL (*ResolveSequencePointDelegate)(PVOID, const char*, unsigned int, unsigned int*, unsigned int*);
typedef BOOL (*GetLocalVariableName)(PVOID, int, int, BSTR*);
typedef BOOL (*GetLineByILOffsetDelegate)(PVOID, mdMethodDef, ULONG64, ULONG *, BSTR*);

class SymbolReader
{
private:
#ifndef FEATURE_PAL
ISymUnmanagedReader* m_pSymReader;
#endif
ULONG64 m_symbolReaderHandle;
PVOID m_symbolReaderHandle;

static LoadSymbolsForModuleDelegate loadSymbolsForModuleDelegate;
static DisposeDelegate disposeDelegate;
Expand Down

0 comments on commit db3994a

Please sign in to comment.