3
#include "win/autoswitch.h"
10
ContextAutoRestoreIf::ContextAutoRestoreIf(bool skipContextRestore)
14
m_skipRestore = skipContextRestore;
18
memset( &m_localContext, 0, sizeof(m_localContext) );
19
memset( &m_currentFrame, 0, sizeof(m_currentFrame) );
21
m_quietState = g_dbgMgr->setQuietNotiification(true);
23
hres = g_dbgMgr->system->GetCurrentThreadId(&m_currentThread);
29
hres = g_dbgMgr->system->GetCurrentProcessId(&m_currentProcess);
32
m_currentProcess = -1;
35
hres = g_dbgMgr->system->GetCurrentSystemId(&m_currentSystem);
41
m_savedRegCtx = false;
42
m_savedLocalContext = false;
43
m_savedCurrentFrame = false;
46
hres = g_dbgMgr->registers->GetValues2(DEBUG_REGSRC_EXPLICIT, 1, NULL, 0, ®Val);
49
hres = g_dbgMgr->symbols->GetScope(&m_instructionOffset, NULL, &m_localContext, sizeof(m_localContext));
50
m_savedLocalContext = (S_OK == hres);
53
hres = g_dbgMgr->symbols->GetScope(&m_instructionOffset, &m_currentFrame, NULL, 0);
54
m_savedCurrentFrame = (S_OK == hres);
60
ContextAutoRestoreIf::~ContextAutoRestoreIf()
65
if (m_currentSystem != -1)
66
g_dbgMgr->system->SetCurrentSystemId(m_currentSystem);
68
if (m_currentProcess != -1)
69
g_dbgMgr->system->SetCurrentProcessId(m_currentProcess);
71
if (m_currentThread != -1)
72
g_dbgMgr->system->SetCurrentThreadId(m_currentThread);
75
g_dbgMgr->registers->SetValues2(DEBUG_REGSRC_EXPLICIT, static_cast<ULONG>(m_regValues.size()), NULL, 0, &m_regValues[0]);
77
if (m_savedLocalContext)
78
g_dbgMgr->symbols->SetScope(m_instructionOffset, NULL, &m_localContext, sizeof(m_localContext));
80
if (m_savedCurrentFrame)
81
g_dbgMgr->symbols->SetScope(m_instructionOffset, &m_currentFrame, NULL, 0);
83
g_dbgMgr->setQuietNotiification(m_quietState);