• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 #ifndef JDWP_OUTSTREAM_H
27 #define JDWP_OUTSTREAM_H
28 
29 #include "transport.h"
30 #include "FrameID.h"
31 
32 struct bag;
33 
34 #define INITIAL_SEGMENT_SIZE   300
35 #define MAX_SEGMENT_SIZE     10000
36 
37 typedef struct PacketData {
38     int length;
39     jbyte *data;
40     struct PacketData *next;
41 } PacketData;
42 
43 typedef struct PacketOutputStream {
44     jbyte *current;
45     jint left;
46     struct PacketData *segment;
47     struct PacketData firstSegment;
48     jvmtiError error;
49     jboolean sent;
50     jdwpPacket packet;
51     jbyte initialSegment[INITIAL_SEGMENT_SIZE];
52     struct bag *ids;
53 } PacketOutputStream;
54 
55 void outStream_initCommand(PacketOutputStream *stream, jint id,
56                            jbyte flags, jbyte commandSet, jbyte command);
57 void outStream_initReply(PacketOutputStream *stream, jint id);
58 
59 jint outStream_id(PacketOutputStream *stream);
60 jbyte outStream_command(PacketOutputStream *stream);
61 
62 jdwpError outStream_writeBoolean(PacketOutputStream *stream, jboolean val);
63 jdwpError outStream_writeByte(PacketOutputStream *stream, jbyte val);
64 jdwpError outStream_writeChar(PacketOutputStream *stream, jchar val);
65 jdwpError outStream_writeShort(PacketOutputStream *stream, jshort val);
66 jdwpError outStream_writeInt(PacketOutputStream *stream, jint val);
67 jdwpError outStream_writeLong(PacketOutputStream *stream, jlong val);
68 jdwpError outStream_writeFloat(PacketOutputStream *stream, jfloat val);
69 jdwpError outStream_writeDouble(PacketOutputStream *stream, jdouble val);
70 jdwpError outStream_writeObjectRef(JNIEnv *env, PacketOutputStream *stream, jobject val);
71 jdwpError outStream_writeObjectTag(JNIEnv *env, PacketOutputStream *stream, jobject val);
72 jdwpError outStream_writeFrameID(PacketOutputStream *stream, FrameID val);
73 jdwpError outStream_writeMethodID(PacketOutputStream *stream, jmethodID val);
74 jdwpError outStream_writeFieldID(PacketOutputStream *stream, jfieldID val);
75 jdwpError outStream_writeLocation(PacketOutputStream *stream, jlocation val);
76 jdwpError outStream_writeByteArray(PacketOutputStream*stream, jint length, jbyte *bytes);
77 jdwpError outStream_writeString(PacketOutputStream *stream, char *string);
78 jdwpError outStream_writeValue(JNIEnv *env, struct PacketOutputStream *out,
79                           jbyte typeKey, jvalue value);
80 jdwpError outStream_skipBytes(PacketOutputStream *stream, jint count);
81 
82 jdwpError outStream_error(PacketOutputStream *stream);
83 void outStream_setError(PacketOutputStream *stream, jdwpError error);
84 
85 void outStream_sendReply(PacketOutputStream *stream);
86 void outStream_sendCommand(PacketOutputStream *stream);
87 
88 void outStream_destroy(PacketOutputStream *stream);
89 
90 #endif
91