GDBServerFoundation::BreakInSocket Class Reference

Encapsulates a socket with asynchronous break-in support. More...

#include <BreakInSocket.h>

Classes

class  SocketWrapper
 An instance of this class should be obtained and held for the entire time when a packet is received. After it is destroyed, the break-in detector thread becomes active again. More...
 

Public Types

enum  { kBreakInByte = 0x03 }
 

Public Member Functions

 BreakInSocket (BazisLib::Network::TCPSocketEx *pSock)
 
 ~BreakInSocket ()
 
size_t Send (const void *pBuffer, size_t size)
 
void SetTarget (IBreakInTarget *pTarget)
 

Detailed Description

Encapsulates a socket with asynchronous break-in support.

This class should be used to receive packets from GDB. The main packet handling loop should look this way:

  1. Create an instance of BreakInSocket::SocketWrapper
  2. Use SocketWrapper to get read the packet. If the first byte received from the socket is 0x03, raise the break-in event.
  3. If TCPSocketEx::Peek() was called, call TCPSocketEx::Discard()
  4. Delete the BreakInSocket::SocketWrapper instance
  5. Process the packet, send reply, etc.

The BreakInSocket class ensures that if a break-in request (0x03 byte) arrives while the packet is being processed (i.e. BreakInSocket::SocketWrapper not existing), a IBreakInTarget::OnBreakInRequest() will be called from a worker thread.

This allows the packet handlers to run blocking requests (e.g. 'continue') and still being able to react to the asynchronous break-in requests coming from GDB.

Remarks
When an instance of BreakInSocket::SocketWrapper is active, the worker thread is suspended and does not interfere with the socket. As soon as the BreakInSocket::SocketWrapper instance is deleted, the worker thread starts monitoring the socket. If it receives anything except the 0x03 byte (i.e. start of a packet), it suspends itself until the packet is handled (i.e. an instance of BreakInSocket::SocketWrapper is created and deleted).

Member Enumeration Documentation

anonymous enum
Enumerator:
kBreakInByte 

Constructor & Destructor Documentation

GDBServerFoundation::BreakInSocket::BreakInSocket ( BazisLib::Network::TCPSocketEx *  pSock)
inline
GDBServerFoundation::BreakInSocket::~BreakInSocket ( )
inline

Member Function Documentation

size_t GDBServerFoundation::BreakInSocket::Send ( const void *  pBuffer,
size_t  size 
)
inline
void GDBServerFoundation::BreakInSocket::SetTarget ( IBreakInTarget pTarget)
inline

The documentation for this class was generated from the following file: