Methods Summary |
---|
public void | Handshake()Performs JDWP "handshake" procedure (undocumented ?). It sends
a "JDWP-Handshake" string and waits for receiving the
same string. After handshaking the JDWP connection is considered
estblished.
String hs = "JDWP-Handshake";
byte[] hsb = hs.getBytes();
write(hsb, 0, hsb.length);
int handshakeTime = handshakeTimeout;
do{
Tools.wait(500);
handshakeTime -= 500;
}while(handshakeTime > 0 && available() < hsb.length);
if (available() < hsb.length)
throw new IOException("Target failed to handshake.");
for (int i = 0; i < hsb.length; i++) {
byte b = (byte) (read() & 0xFF);
if (b != hsb[i])
throw new IOException("Target failed to handshake.");
}
|
public abstract int | available()Returns the number of bytes that can be received immediately.
|
public abstract int | read()Receives the next byte of data. The value byte is
returned as an int in the range 0 to 255. If no byte is
available, the value -1 is returned.
|
public void | receive()Receives all available JDWP reply packets and places them into the
vector Replies . This method is overwritten in KJDB and the
code below is not used.
while (available() > 0)
buffer.addByte(read());
while (buffer.length() >= Packet.PacketHeaderSize) {
int size = 0;
buffer.resetParser();
try {
size = buffer.getInt();
}
catch (BoundException e) {}
if ((size < 0) || (size > MaxPacketSize))
throw new IOException("Wrong JDWP packet size: " + size + ".");
if (size > buffer.length())
return;
Reply r = new Reply();
r.resetBuffer();
r.addBytes(buffer.bytes, 0, size);
buffer.deleteBytes(size);
Replies.add(r);
}
|
public Reply | receiveEvent(int command, int Delay)Tries to receive a JDWP event. It looks
into a list of already received packets and tries to locate it.
If the desired packet is not found, is makes a pause and then
tries to receive the deired reply again.
In case of timeout Reply.errNotAvailable
is returned.
Reply r;
while (Delay > 0) {
receive();
for (int i = 0; i < Replies.size(); i++) {
r = (Reply) Replies.elementAt(i);
if (r.getFlags() == 0 && r.getErrorCode() == command)
return (Reply) Replies.remove(i);
}
Tools.wait(delta);
Delay = Delay - delta;
}
return Reply.Error(Reply.errNotAvailable);
|
public Reply | receiveReply(int ReplyID)Tries to receive a JDWP reply packet with specified ID. It looks
into a list of already received packets and tries to locate it.
If the desired packet is not found, Reply.errNotAvailable
is returned.
receive();
for (int i = 0; i < Replies.size(); i++)
if (((Reply) Replies.elementAt(i)).getFlags() == 0x80 &&
((Reply) Replies.elementAt(i)).getID() == ReplyID)
return (Reply) Replies.remove(i);
return Reply.Error(Reply.errNotAvailable);
|
public Reply | receiveReply(int ReplyID, int Delay)Tries to receive a JDWP reply packet with specified ID. It looks
into a list of already received packets and tries to locate it.
If the desired packet is not found, is makes a pause and then
tries to receive the deired reply again.
In case of timeout Reply.errNotAvailable
is returned.
Reply r = receiveReply(ReplyID);
while ((r.getErrorCode() == Reply.errNotAvailable) && (Delay > 0)) {
Tools.wait(delta);
r = receiveReply(ReplyID);
Delay = Delay - delta;
}
return r;
|
public Reply | receiveReply()Receives JDWP reply packet.
If there is no reply packet available, function returns packet
with error code Reply.errNotAvailable .
receive();
if (Replies.size() == 0)
return Reply.Error(Reply.errNotAvailable);
return (Reply) Replies.remove(0);
|
public void | sendBadCommandPacket(Command c, int WrongSize)Sends JDWP command packet with wrong length field. This method is
never used by KJDB but it's used by CLDC-DI and JavaCard BackEnd
test suite.
try {
c.putInt(Packet.LengthOffset, WrongSize);
}
catch (BoundException e) {};
write(c.bytes, 0, c.length());
|
public void | sendCommand(Command c)Sends JDWP command packet.
c.setLength();
write(c.bytes, 0, c.length());
|
public abstract void | write(int b)Sends the specified byte via JDWP.
|
public void | write(byte[] b, int off, int len)Sends the specified bytes via JDWP.
for (int i = 0; i < len; i++)
write(b[off + i]);
|