Skip to content

Commit

Permalink
ifdef Linux specific readvirtual code (dotnet/coreclr#25299)
Browse files Browse the repository at this point in the history
Commit migrated from dotnet/coreclr@821a5d2
  • Loading branch information
mikem8361 authored Jun 21, 2019
1 parent f2b8b5e commit d55c339
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/coreclr/src/debug/di/shimremotedatatarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class ShimRemoteDataTarget : public ShimDataTarget
private:
DbgTransportTarget * m_pProxy;
DbgTransportSession * m_pTransport;
#ifndef __APPLE__
int m_fd; // /proc/<pid>/mem handle
#endif
};


Expand Down Expand Up @@ -104,9 +106,11 @@ ShimRemoteDataTarget::ShimRemoteDataTarget(DWORD processId,
m_fpContinueStatusChanged = NULL;
m_pContinueStatusChangedUserData = NULL;

#ifndef __APPLE__
char memPath[128];
_snprintf_s(memPath, sizeof(memPath), sizeof(memPath), "/proc/%lu/mem", m_processId);
m_fd = _open(memPath, 0); // O_RDONLY
#endif
}

//---------------------------------------------------------------------------------------
Expand All @@ -131,11 +135,13 @@ ShimRemoteDataTarget::~ShimRemoteDataTarget()

void ShimRemoteDataTarget::Dispose()
{
#ifndef __APPLE__
if (m_fd != -1)
{
_close(m_fd);
m_fd = -1;
}
#endif
if (m_pTransport != NULL)
{
m_pProxy->ReleaseTransport(m_pTransport);
Expand Down Expand Up @@ -263,6 +269,7 @@ ShimRemoteDataTarget::ReadVirtual(
size_t read = cbRequestSize;
HRESULT hr = S_OK;

#ifndef __APPLE__
if (m_fd != -1)
{
read = _pread(m_fd, pBuffer, cbRequestSize, (ULONG64)address);
Expand All @@ -272,6 +279,7 @@ ShimRemoteDataTarget::ReadVirtual(
}
}
else
#endif
{
hr = m_pTransport->ReadMemory(reinterpret_cast<BYTE *>(CORDB_ADDRESS_TO_PTR(address)), pBuffer, cbRequestSize);
}
Expand Down

0 comments on commit d55c339

Please sign in to comment.