Methods Summary |
---|
public Reply | checkReply(Command c, int ErrorCode, java.lang.String Description)Sends JDWP command and waits for reply. The method expects that
JDWP reply packet will contain expected error code otherwise
DebugeeException is raised. Currently this method is used
internally by othe methods of BackEndTest .
Reply r = checkReply(c);
if (r.getErrorCode() != ErrorCode) {
print("\nCommand:\n" + c + "\nReply:\n" + r);
String m = "Unexpected error code";
if (! Description.equals(""))
Description = "Unexpected error code (" + Description + ").";
else
Description = "Unexpected error code.";
throw new DebugeeException (Description);
}
return r;
|
public Reply | checkReply(Command c)Sends JDWP command and waits for reply. If reply is not received in
100 seconds DebugeeException is raised. So large timeout
is choosen because of possibility of using extremely slow
or busy systems where VM being debugged is run. This method is
used internally by other BackEndTest methods. Also
it's a good idea to explicity invoke this method when non-zero
error code in considered as correct or allowable answer.
sendCommand(c);
Reply r = debug.receiveReply(c.getID(), 100000);
if (r.getErrorCode() == Reply.errNotAvailable) {
print("\nCommand:\n" + c);
printReplies();
throw new DebugeeException("Reply packet is not received.");
}
return r;
|
public void | closeConnections()Closes connection. This function is executed prior to
KJDB finishing.
if (debug != null) {
try {
debug.done();
} catch (Exception e) {};
debug = null;
}
is_connected = false;
|
public void | connect(java.lang.String hostName, int port)
try{
openConnections(hostName, port);
is_connected = true;
}catch(DebugeeException e){
throw new ConnectException(e.getMessage());
}catch(IOException e){
throw new ConnectException(e.getMessage());
}
|
public void | getIDSizes()Determines the sizes (in bytes ) of field IDs,
method IDs, object reference IDs and reference type IDs.
These values are VM specific and are obtained via
VirtualMachine/IDSizes JDWP command. This method is invoked by
openConnections(String, int) method immediately after
establishing JDWP connection.
try{
Command c;
Reply r;
c = new Command(0x0107);
r = checkReply(c);
r.resetDataParser();
fieldIDSize = r.getInt();
methodIDSize = r.getInt();
objectIDSize = r.getInt();
referenceTypeIDSize = r.getInt();
frameIDSize = r.getInt();
}catch(Exception e){
throw new DebugeeException("Exception occured in IDSizes function");
}
|
public boolean | isConnected()
return is_connected;
|
private void | openConnections(java.lang.String debugee_server, int debugee_port)Connects to VM being debugged.
try {
Tools.wait(1000);
debug = new SocketTransport();
debug.attachToServer(debugee_server, debugee_port);
debug.Handshake();
}
catch (Exception e) {
System.err.println("* Exception.\n");
throw new ConnectException("Can't create JDWP connection.");
}
System.out.println("* JDWP connection is installed.");
getIDSizes();
|
public static void | print(java.lang.String s)Debug time method. Rewrite it if you'd like to see debug output
not in the standard output
if (s.equals(""))
return;
System.out.println(s);
|
public static void | print(java.util.Vector v)Debug time method. Prints the content of the vector to standard
output.
System.out.println(Tools.listVector(v));
|
public static void | print(Packet p, java.lang.String how)Debug time method. Prints the content of JDWP package in specified manner.
print(p.parse(how));
|
public void | printReplies()Prints all JDWP replies that were not demanded yet. This method is
invoked when no expected reply is received that is considered as
fatal error.
debug.receive();
if (debug.Replies.size() == 0)
return;
print("\nReplies:\n");
for (int i = 0; i < debug.Replies.size(); i++)
print("\n" + (Reply) debug.Replies.elementAt(i) + "\n");
|
public void | sendCommand(int command)
sendCommand(new Command(command));
|
public Command | sendCommand(Command c)This method sends JDWP command and does not wait for answer. It's
used internally by other BackEndTest methods. Also
it's a good idea to use this method in some cases when answer is not
guaranteered (for example, if you send VirtualMachine/Resume
JDWP command you may receive no answer because of debugging session
finishing).
try{
debug.sendCommand(c);
}catch (IOException e){
throw new DebugeeException(e.getMessage());
}
return c;
|
public VMReply | sendReplyCommand(int command, int[] params)
try {
Command cmd = new Command(command);
for (int i = 0; i < params.length; i++) {
cmd.addInt(params[i]);
}
Reply reply = checkReply(cmd);
reply.resetDataParser();
return reply;
} catch (IOException e) {
throw new DebugeeException(e.getMessage());
}
|
public VMReply | sendReplyCommand(int command)
try {
Reply reply = checkReply(new Command(command));
reply.resetDataParser();
return reply;
} catch (IOException e) {
throw new DebugeeException(e.getMessage());
}
|