|
Message
From: cvs at opencores.org<cvs@o...>
Date: Tue Dec 18 03:47:58 CET 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/12 18:03:47 Modified: jop/java/target/src/test/debug/io JavaDebugPacket.java Log: Added some methods and fixed a bug on the code for setFlags. Methods added: 206: public synchronized void skipBytes(int numBytes) 438: public boolean hasNoError() 657: public void printPacketHeader(PrintStream out) 662: public static void printPacketHeader(JavaDebugPacket packet, PrintStream out) Method changed: 369: public synchronized void setFlags(int value) Revision Changes Path 1.3 jop/java/target/src/test/debug/io/JavaDebugPacket.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/debug/io/JavaDebugPacket.java.diff?r1=1.2&r2=1.3 (In the diff below, changes in quantity of whitespace are not shown.) Index: JavaDebugPacket.java =================================================================== RCS file: /cvsroot/paulo/jop/java/target/src/test/debug/io/JavaDebugPacket.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- JavaDebugPacket.java 12 Dec 2007 23:58:56 -0000 1.2 +++ JavaDebugPacket.java 18 Dec 2007 02:47:57 -0000 1.3 @@ -24,8 +24,10 @@ import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStream; +import java.io.PrintStream; import debug.constants.CommandConstants; +import debug.constants.ErrorConstants; /** * This class model a JDWP packet for JOP. @@ -160,6 +162,10 @@ value = arrayOutputStream.readInt(this.readIndex); readIndex += 4; + + //JopDebugKernel.debugPrint("ReadInt: "); + //JopDebugKernel.debugPrintln(value); + return value; } @@ -192,6 +198,20 @@ } /** + * Skip some bytes from the packet content. + * The numBytes parameter should be positive or will be ignored. + * + * @param numBytes + */ + public synchronized void skipBytes(int numBytes) + { + if(numBytes > 0) + { + readIndex += numBytes; + } + } + + /** * Read an entire packet from the given input and store its content * in memory for later access. Discard previous data. * @@ -368,7 +388,7 @@ */ public synchronized void setFlags(int value) { - arrayOutputStream.overwriteInt(value, FLAGS_INDEX); + arrayOutputStream.overwriteByte(value, FLAGS_INDEX); } /** @@ -407,6 +427,21 @@ } /** + * Check if this is a reply package which has no error set. + * + * This method can be used only for reply packets. + * It has no meaning for regular request packets: in this + * case, it will always return "false".
+ *
+ * @return
+ */
+ public boolean hasNoError()
+ {
+ // check if it's a reply packet and also if there's no error set.
+ return isReply() && (getErrorCode() == ErrorConstants.ERROR_NONE);
+ }
+
+ /**
* Read a set of bytes from the buffer.
*
* @param location
@@ -618,4 +653,61 @@
createReplyHeader(id, commandSet, command);
}
+
+ public void printPacketHeader(PrintStream out)
+ {
+ printPacketHeader(this, out);
+ }
+
+ public static void printPacketHeader(JavaDebugPacket packet, PrintStream out)
+ {
+ int id;
+ int commandSet;
+ int command;
+ int size;
+ int flags;
+
+ size = packet.getLength();
+ id = packet.getId();
+ flags = packet.getFlags();
+ commandSet = packet.getCommandSet();
+ command = packet.getCommand();
+
+ out.print(" Size: ");
+ out.print(size);
+
+ out.print(" ID: ");
+ out.print(id);
+
+ out.print(" Flags: ");
+ out.print(flags);
+
+
+ if(packet.isReply() == false)
+ {
+ out.print(" Command Set: ");
+ out.print(commandSet);
+ out.print(" ");
+ out.print(CommandConstants.getSetDescription(commandSet));
+
+ out.print(" Command: ");
+ out.print(command);
+ out.print(" ");
+ out.println(CommandConstants.getCommandDescription(commandSet, command));
+ }
+ else
+ {
+ out.print(" Error code: ");
+ if(packet.hasNoError())
+ {
+ out.println("None");
+ }
+ else
+ {
+ int error = packet.getErrorCode();
+ out.println(error);
+ }
+ }
+ out.println();
+ }
}
\ No newline at end of file
|
 |