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

Commit

Permalink
Unify ReadXXX/LocateXXX into GetXXXLocation, and RestoreXXX/TrashXXX …
Browse files Browse the repository at this point in the history
…into SetXXXLocation
  • Loading branch information
parjong committed Jan 31, 2017
1 parent 89969bf commit c56cc86
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 129 deletions.
14 changes: 7 additions & 7 deletions src/debug/daccess/dacdbiimplstackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,13 +1156,13 @@ void DacDbiInterfaceImpl::UpdateContextFromRegDisp(REGDISPLAY * pRegDisp,
// Do a partial copy first.
pContext->ContextFlags = (CONTEXT_INTEGER | CONTEXT_CONTROL);

pContext->Edi = pRegDisp->ReadEdi();
pContext->Esi = pRegDisp->ReadEsi();
pContext->Ebx = pRegDisp->ReadEbx();
pContext->Ebp = pRegDisp->ReadEbp();
pContext->Eax = pRegDisp->ReadEax();
pContext->Ecx = pRegDisp->ReadEcx();
pContext->Edx = pRegDisp->ReadEdx();
pContext->Edi = *pRegDisp->GetEdiLocation();
pContext->Esi = *pRegDisp->GetEsiLocation();
pContext->Ebx = *pRegDisp->GetEbxLocation();
pContext->Ebp = *pRegDisp->GetEbpLocation();
pContext->Eax = *pRegDisp->GetEaxLocation();
pContext->Ecx = *pRegDisp->GetEcxLocation();
pContext->Edx = *pRegDisp->GetEdxLocation();
pContext->Esp = pRegDisp->SP;
pContext->Eip = pRegDisp->ControlPC;

Expand Down
14 changes: 7 additions & 7 deletions src/debug/ee/debugger.inl
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ inline void FuncEvalFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
// Update all registers in the reg display from the CONTEXT we stored when the thread was hijacked for this func
// eval. We have to update all registers, not just the callee saved registers, because we can hijack a thread at any
// point for a func eval, not just at a call site.
pRD->RestoreEdi(&(pDE->m_context.Edi));
pRD->RestoreEsi(&(pDE->m_context.Esi));
pRD->RestoreEbx(&(pDE->m_context.Ebx));
pRD->RestoreEdx(&(pDE->m_context.Edx));
pRD->RestoreEcx(&(pDE->m_context.Ecx));
pRD->RestoreEax(&(pDE->m_context.Eax));
pRD->RestoreEbp(&(pDE->m_context.Ebp));
pRD->SetEdiLocation(&(pDE->m_context.Edi));
pRD->SetEsiLocation(&(pDE->m_context.Esi));
pRD->SetEbxLocation(&(pDE->m_context.Ebx));
pRD->SetEdxLocation(&(pDE->m_context.Edx));
pRD->SetEcxLocation(&(pDE->m_context.Ecx));
pRD->SetEaxLocation(&(pDE->m_context.Eax));
pRD->SetEbpLocation(&(pDE->m_context.Ebp));
pRD->SP = (DWORD)GetSP(&pDE->m_context);
pRD->PCTAddr = GetReturnAddressPtr();
pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
Expand Down
14 changes: 7 additions & 7 deletions src/debug/ee/i386/x86walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,28 @@ DWORD NativeWalker::GetRegisterValue(int registerNumber)
switch (registerNumber)
{
case 0:
return m_registers->ReadEax();
return *m_registers->GetEaxLocation();
break;
case 1:
return m_registers->ReadEcx();
return *m_registers->GetEcxLocation();
break;
case 2:
return m_registers->ReadEdx();
return *m_registers->GetEdxLocation();
break;
case 3:
return m_registers->ReadEbx();
return *m_registers->GetEbxLocation();
break;
case 4:
return m_registers->SP;
break;
case 5:
return m_registers->ReadEbp();
return *m_registers->GetEbpLocation();
break;
case 6:
return m_registers->ReadEsi();
return *m_registers->GetEsiLocation();
break;
case 7:
return m_registers->ReadEdi();
return *m_registers->GetEdiLocation();
break;
default:
_ASSERTE(!"Invalid register number!");
Expand Down
12 changes: 6 additions & 6 deletions src/debug/shared/i386/primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ void SetDebuggerREGDISPLAYFromREGDISPLAY(DebuggerREGDISPLAY* pDRD, REGDISPLAY* p
// Frame pointer
LPVOID FPAddress = GetRegdisplayFPAddress(pRD);
pDRD->FP = (FPAddress == NULL ? 0 : *((SIZE_T *)FPAddress));
pDRD->Edi = (pRD->LocateEdi() == NULL ? 0 : pRD->ReadEdi());
pDRD->Esi = (pRD->LocateEsi() == NULL ? 0 : pRD->ReadEsi());
pDRD->Ebx = (pRD->LocateEbx() == NULL ? 0 : pRD->ReadEbx());
pDRD->Edx = (pRD->LocateEdx() == NULL ? 0 : pRD->ReadEdx());
pDRD->Ecx = (pRD->LocateEcx() == NULL ? 0 : pRD->ReadEcx());
pDRD->Eax = (pRD->LocateEax() == NULL ? 0 : pRD->ReadEax());
pDRD->Edi = (pRD->GetEdiLocation() == NULL ? 0 : *pRD->GetEdiLocation());
pDRD->Esi = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEsiLocation());
pDRD->Ebx = (pRD->GetEbxLocation() == NULL ? 0 : *pRD->GetEbxLocation());
pDRD->Edx = (pRD->GetEdxLocation() == NULL ? 0 : *pRD->GetEdxLocation());
pDRD->Ecx = (pRD->GetEcxLocation() == NULL ? 0 : *pRD->GetEcxLocation());
pDRD->Eax = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEaxLocation());

#if defined(USE_REMOTE_REGISTER_ADDRESS)
pDRD->pFP = PushedRegAddr(pRD, FPAddress);
Expand Down
36 changes: 17 additions & 19 deletions src/inc/regdisp.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,26 @@ struct REGDISPLAY : public REGDISPLAY_BASE {
DWORD * pEsi;
DWORD * pEdi;
DWORD * pEbp;
#endif // !WIN64EXCEPTIONS

#ifndef WIN64EXCEPTIONS

#define VOLATILE_REG_METHODS(reg) \
inline DWORD Read##reg(void) { return *p##reg; } \
inline PDWORD Locate##reg(void) { return p##reg; } \
inline void Restore##reg(PDWORD p##reg) { this->p##reg = p##reg; } \
inline void Trash##reg(PDWORD p##reg) { this->p##reg = p##reg; }
inline PDWORD Get##reg##Location(void) { return p##reg; } \
inline void Set##reg##Location(PDWORD p##reg) { this->p##reg = p##reg; }

#define NONVOLATILE_REG_METHODS(reg) VOLATILE_REG_METHODS(reg)

#else // !WIN64EXCEPTIONS

#define VOLATILE_REG_METHODS(reg) \
inline DWORD Read##reg(void) { return pCurrentContext->reg; } \
inline PDWORD Locate##reg(void) { return NULL; } \
inline void Restore##reg(PDWORD p##reg) { pCurrentContext->reg = *p##reg; } \
inline void Trash##reg(PDWORD p##reg) { pCurrentContext->reg = *p##reg; }
inline PDWORD Get##reg##Location(void) { return &pCurrentContext->reg; } \
inline void Set##reg##Location(PDWORD p##reg) { pCurrentContext->reg = *p##reg; }

#define NONVOLATILE_REG_METHODS(reg) \
inline DWORD Read##reg(void) { return pCurrentContext->reg; } \
inline PDWORD Locate##reg(void) { return (pCurrentContextPointers) ? pCurrentContextPointers->reg : NULL; } \
inline void Restore##reg(PDWORD p##reg) { if (pCurrentContextPointers) { pCurrentContextPointers->reg = p##reg; } pCurrentContext->reg = *p##reg; } \
inline void Trash##reg(PDWORD p##reg) { if (pCurrentContextPointers) { pCurrentContextPointers->reg = NULL; } pCurrentContext->reg = *p##reg; }
inline PDWORD Get##reg##Location(void) { return (pCurrentContextPointers) ? pCurrentContextPointers->reg : &pCurrentContext->reg; } \
inline void Set##reg##Location(PDWORD p##reg) { if (pCurrentContextPointers) { pCurrentContextPointers->reg = p##reg; } pCurrentContext->reg = *p##reg; }

#endif // WIN64EXCEPTIONS

VOLATILE_REG_METHODS(Eax)
Expand All @@ -117,21 +115,21 @@ struct REGDISPLAY : public REGDISPLAY_BASE {
TAG_EBP
};

inline void Restore(TAG tag, PDWORD pReg)
inline void SetLocation(TAG tag, PDWORD pReg)
{
switch (tag)
{
case TAG_EBX:
RestoreEbx(pReg);
SetEbxLocation(pReg);
break;
case TAG_ESI:
RestoreEsi(pReg);
SetEsiLocation(pReg);
break;
case TAG_EDI:
RestoreEdi(pReg);
SetEdiLocation(pReg);
break;
case TAG_EBP:
RestoreEbp(pReg);
SetEbpLocation(pReg);
break;
default:
_ASSERTE(!"Invalid register");
Expand All @@ -155,13 +153,13 @@ inline void SetRegdisplaySP(REGDISPLAY *display, LPVOID sp ) {
inline TADDR GetRegdisplayFP(REGDISPLAY *display) {
LIMITED_METHOD_DAC_CONTRACT;

return (TADDR)display->ReadEbp();
return (TADDR)*display->GetEbpLocation();
}

inline LPVOID GetRegdisplayFPAddress(REGDISPLAY *display) {
LIMITED_METHOD_CONTRACT;

return (LPVOID)display->LocateEbp();
return (LPVOID)display->GetEbpLocation();
}

inline PCODE GetControlPC(REGDISPLAY *display) {
Expand Down
Loading

0 comments on commit c56cc86

Please sign in to comment.