#include "dbgtransportsession.h"
#include "dbgtransportmanager.h"
-
class ShimRemoteDataTarget : public ShimDataTarget
{
public:
private:
DbgTransportTarget * m_pProxy;
DbgTransportSession * m_pTransport;
+ int m_fd; // /proc/<pid>/mem handle
};
m_fpContinueStatusChanged = NULL;
m_pContinueStatusChangedUserData = NULL;
+
+ char memPath[128];
+ _snprintf_s(memPath, sizeof(memPath), sizeof(memPath), "/proc/%lu/mem", m_processId);
+ m_fd = _open(memPath, 0); // O_RDONLY
}
//---------------------------------------------------------------------------------------
void ShimRemoteDataTarget::Dispose()
{
+ if (m_fd != -1)
+ {
+ _close(m_fd);
+ m_fd = -1;
+ }
if (m_pTransport != NULL)
{
m_pProxy->ReleaseTransport(m_pTransport);
}
-
m_pTransport = NULL;
m_hr = CORDBG_E_OBJECT_NEUTERED;
}
// impl of interface method ICorDebugDataTarget::ReadVirtual
HRESULT STDMETHODCALLTYPE
-ShimRemoteDataTarget::ReadVirtual(
+ShimRemoteDataTarget::ReadVirtual(
CORDB_ADDRESS address,
PBYTE pBuffer,
ULONG32 cbRequestSize,
{
ReturnFailureIfStateNotOk();
- HRESULT hr = E_FAIL;
- hr = m_pTransport->ReadMemory(reinterpret_cast<BYTE *>(CORDB_ADDRESS_TO_PTR(address)),
- pBuffer,
- cbRequestSize);
+ size_t read = cbRequestSize;
+ HRESULT hr = S_OK;
+
+ if (m_fd != -1)
+ {
+ read = _pread(m_fd, pBuffer, cbRequestSize, (ULONG64)address);
+ if (read == -1)
+ {
+ hr = E_FAIL;
+ }
+ }
+ else
+ {
+ hr = m_pTransport->ReadMemory(reinterpret_cast<BYTE *>(CORDB_ADDRESS_TO_PTR(address)), pBuffer, cbRequestSize);
+ }
if (pcbRead != NULL)
{
- *pcbRead = (SUCCEEDED(hr) ? cbRequestSize : 0);
+ *pcbRead = (SUCCEEDED(hr) ? read : 0);
}
return hr;
}
#define _strdup PAL__strdup
#define _getcwd PAL__getcwd
#define _open PAL__open
+#define _pread PAL__pread
#define _close PAL__close
#define _wcstoui64 PAL__wcstoui64
#define _flushall PAL__flushall
#endif // !PAL_STDCPP_COMPAT
PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);
-PALIMPORT int __cdecl _close(int);
+PALIMPORT DLLEXPORT int __cdecl _open(const char *szPath, int nFlags, ...);
+PALIMPORT DLLEXPORT size_t __cdecl _pread(int fd, void *buf, size_t nbytes, ULONG64 offset);
+PALIMPORT DLLEXPORT int __cdecl _close(int);
PALIMPORT DLLEXPORT int __cdecl _flushall();
#ifdef PAL_STDCPP_COMPAT