forked from sysprogs/msp430-gdbproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalSessionMonitor.cpp
43 lines (37 loc) · 1.05 KB
/
GlobalSessionMonitor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "stdafx.h"
#include "GlobalSessionMonitor.h"
using namespace BazisLib;
using namespace MSP430Proxy;
GlobalSessionMonitor MSP430Proxy::g_SessionMonitor;
bool MSP430Proxy::GlobalSessionMonitor::RegisterSession( ISyncGDBTarget *pTarget )
{
MutexLocker lck(g_SessionMonitor.m_Mutex);
if (pSession)
return false;
pSession = pTarget;
return true;
}
void MSP430Proxy::GlobalSessionMonitor::UnregisterSession( ISyncGDBTarget *pTarget )
{
MutexLocker lck(g_SessionMonitor.m_Mutex);
ASSERT(pSession == pTarget);
pSession = NULL;
}
MSP430Proxy::GlobalSessionMonitor::GlobalSessionMonitor()
: pSession(NULL)
{
SetConsoleCtrlHandler(CtrlHandler, TRUE);
}
BOOL CALLBACK MSP430Proxy::GlobalSessionMonitor::CtrlHandler( DWORD dwType )
{
if (dwType == CTRL_C_EVENT)
{
MutexLocker lck(g_SessionMonitor.m_Mutex);
if (g_SessionMonitor.pSession)
g_SessionMonitor.pSession->SendBreakInRequestAsync();
else
printf("No active session. To stop listening, press Ctrl+Break.\n");
return TRUE;
}
return FALSE;
}