Envision
A visual programming IDE for object-oriented languages
List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
OODebug::DebugConnector Class Reference

A Connector to a Java VM via the JDWP protocol. More...

Inheritance diagram for OODebug::DebugConnector:

Public Types

using EventListener = std::function< void(Event)>
 

Public Member Functions

 DebugConnector ()
 
 ~DebugConnector ()
 
void addEventListener (Protocol::EventKind kind, EventListener listener)
 Add the listener callback to the connector. More...
 
QList< qint64 > allThreadIds ()
 
int arrayLength (qint64 arrayId)
 
ArrayValues arrayValues (qint64 arrayId, qint32 firstIndex, qint32 length)
 
bool breakAtClassLoad (QString className)
 
qint64 classIdOf (const QString &signature)
 
bool clearBreakpoint (qint32 requestId)
 
void connect (QString vmHostName="localhost", int vmHostPort=4000)
 Connects to the JVM at vmHostName on port vmHostPort. More...
 
QString fileNameForReference (qint64 referenceId)
 
Frames frames (qint64 threadId, qint32 numFrames, qint32 startFrame=0)
 
LineTable lineTable (qint64 classId, qint64 methodId)
 
qint64 methodIdOf (qint64 classId, const QString &signature)
 
bool resume ()
 Resumes the VM, do not use this function inside event handlers, use wantResume instead. More...
 
int setBreakpoint (Location breakLocation)
 
QString signatureOf (qint64 referenceId)
 
int singleStep (qint64 threadId, Protocol::StepSize stepSize=Protocol::StepSize::LINE, Protocol::StepDepth stepDepth=Protocol::StepDepth::OVER)
 
QString stringFromId (qint64 stringId)
 
bool suspend ()
 Suspends the execution on the VM and returns true on succes. More...
 
QString threadName (qint64 threadId)
 
Values values (qint64 threadId, qint64 frameId, QList< StackVariable > variables)
 
VariableTable variableTableForMethod (qint64 classId, qint64 methodId)
 
bool vmAlive ()
 Returns if the program on the target VM is running. More...
 
void wantResume (bool resume)
 Specify that you want to resume, if there are multiple events all should agree otherwise we don't resume. More...
 

Static Public Attributes

static constexpr int NO_RESULT {-1}
 

Private Types

enum class  ResumeRequest : int { NEUTRAL , RESUME , DONTRESUME }
 

Private Member Functions

void checkIdSizes ()
 
void checkVersion ()
 
void dispatchEvents ()
 
void handleComposite (QByteArray data)
 
void handleSocketError (QAbstractSocket::SocketError socketError)
 
void readFromSocket ()
 
void readHandshake ()
 
QByteArray sendCommand (const Command &command)
 Sends the command to the VM and returns the corresponding reply as a QByteArray. More...
 
void sendHandshake ()
 
QByteArray waitForReply (qint32 requestId)
 Waits until the Reply for the request with id requestId is received. More...
 

Private Attributes

QHash< Protocol::EventKind, EventListenereventListeners_
 
QByteArray incompleteData_
 
QList< QByteArray > messagesReadyForProcessing_
 
enum OODebug::DebugConnector::ResumeRequest resumeRequest_
 
QTcpSocket tcpSocket_
 
bool vmAlive_ {}
 

Detailed Description

A Connector to a Java VM via the JDWP protocol.

Member Typedef Documentation

◆ EventListener

using OODebug::DebugConnector::EventListener = std::function<void (Event)>

Member Enumeration Documentation

◆ ResumeRequest

enum OODebug::DebugConnector::ResumeRequest : int
strongprivate
Enumerator
NEUTRAL 
RESUME 
DONTRESUME 

Constructor & Destructor Documentation

◆ DebugConnector()

OODebug::DebugConnector::DebugConnector ( )

◆ ~DebugConnector()

OODebug::DebugConnector::~DebugConnector ( )

Member Function Documentation

◆ addEventListener()

void OODebug::DebugConnector::addEventListener ( Protocol::EventKind  kind,
DebugConnector::EventListener  listener 
)
inline

Add the listener callback to the connector.

The listener is called whenever and Event of type kind is received.

If there is already a listener for this kind the previous one is replaced!

◆ allThreadIds()

QList< qint64 > OODebug::DebugConnector::allThreadIds ( )

◆ arrayLength()

int OODebug::DebugConnector::arrayLength ( qint64  arrayId)

◆ arrayValues()

ArrayValues OODebug::DebugConnector::arrayValues ( qint64  arrayId,
qint32  firstIndex,
qint32  length 
)

◆ breakAtClassLoad()

bool OODebug::DebugConnector::breakAtClassLoad ( QString  className)

◆ checkIdSizes()

void OODebug::DebugConnector::checkIdSizes ( )
private

◆ checkVersion()

void OODebug::DebugConnector::checkVersion ( )
private

◆ classIdOf()

qint64 OODebug::DebugConnector::classIdOf ( const QString &  signature)

◆ clearBreakpoint()

bool OODebug::DebugConnector::clearBreakpoint ( qint32  requestId)

◆ connect()

void OODebug::DebugConnector::connect ( QString  vmHostName = "localhost",
int  vmHostPort = 4000 
)

Connects to the JVM at vmHostName on port vmHostPort.

◆ dispatchEvents()

void OODebug::DebugConnector::dispatchEvents ( )
private

◆ fileNameForReference()

QString OODebug::DebugConnector::fileNameForReference ( qint64  referenceId)

◆ frames()

Frames OODebug::DebugConnector::frames ( qint64  threadId,
qint32  numFrames,
qint32  startFrame = 0 
)

◆ handleComposite()

void OODebug::DebugConnector::handleComposite ( QByteArray  data)
private

◆ handleSocketError()

void OODebug::DebugConnector::handleSocketError ( QAbstractSocket::SocketError  socketError)
private

◆ lineTable()

LineTable OODebug::DebugConnector::lineTable ( qint64  classId,
qint64  methodId 
)

◆ methodIdOf()

qint64 OODebug::DebugConnector::methodIdOf ( qint64  classId,
const QString &  signature 
)

◆ readFromSocket()

void OODebug::DebugConnector::readFromSocket ( )
private

◆ readHandshake()

void OODebug::DebugConnector::readHandshake ( )
private

◆ resume()

bool OODebug::DebugConnector::resume ( )

Resumes the VM, do not use this function inside event handlers, use wantResume instead.

◆ sendCommand()

QByteArray OODebug::DebugConnector::sendCommand ( const Command command)
private

Sends the command to the VM and returns the corresponding reply as a QByteArray.

◆ sendHandshake()

void OODebug::DebugConnector::sendHandshake ( )
private

◆ setBreakpoint()

int OODebug::DebugConnector::setBreakpoint ( Location  breakLocation)

◆ signatureOf()

QString OODebug::DebugConnector::signatureOf ( qint64  referenceId)

◆ singleStep()

int OODebug::DebugConnector::singleStep ( qint64  threadId,
Protocol::StepSize  stepSize = Protocol::StepSize::LINE,
Protocol::StepDepth  stepDepth = Protocol::StepDepth::OVER 
)

◆ stringFromId()

QString OODebug::DebugConnector::stringFromId ( qint64  stringId)

◆ suspend()

bool OODebug::DebugConnector::suspend ( )

Suspends the execution on the VM and returns true on succes.

◆ threadName()

QString OODebug::DebugConnector::threadName ( qint64  threadId)

◆ values()

Values OODebug::DebugConnector::values ( qint64  threadId,
qint64  frameId,
QList< StackVariable variables 
)

◆ variableTableForMethod()

VariableTable OODebug::DebugConnector::variableTableForMethod ( qint64  classId,
qint64  methodId 
)

◆ vmAlive()

bool OODebug::DebugConnector::vmAlive ( )
inline

Returns if the program on the target VM is running.

◆ waitForReply()

QByteArray OODebug::DebugConnector::waitForReply ( qint32  requestId)
private

Waits until the Reply for the request with id requestId is received.

◆ wantResume()

void OODebug::DebugConnector::wantResume ( bool  resume)

Specify that you want to resume, if there are multiple events all should agree otherwise we don't resume.

Note that this function should only be used in event handlers.

Member Data Documentation

◆ eventListeners_

QHash<Protocol::EventKind, EventListener> OODebug::DebugConnector::eventListeners_
private

◆ incompleteData_

QByteArray OODebug::DebugConnector::incompleteData_
private

◆ messagesReadyForProcessing_

QList<QByteArray> OODebug::DebugConnector::messagesReadyForProcessing_
private

◆ NO_RESULT

constexpr int OODebug::DebugConnector::NO_RESULT {-1}
staticconstexpr

◆ resumeRequest_

enum OODebug::DebugConnector::ResumeRequest OODebug::DebugConnector::resumeRequest_
private

◆ tcpSocket_

QTcpSocket OODebug::DebugConnector::tcpSocket_
private

◆ vmAlive_

bool OODebug::DebugConnector::vmAlive_ {}
private