src/jdk.jdwp.agent/share/native/libjdwp/inStream.c
author clanger
Tue, 12 Dec 2017 09:16:12 +0100
changeset 48242 61e60548c0cf
parent 47216 71c04702a3d5
permissions -rw-r--r--
8193258: Better usage of JDWP HEADER SIZE Reviewed-by: sspitsyn, cjplummer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
48242
61e60548c0cf 8193258: Better usage of JDWP HEADER SIZE
clanger
parents: 47216
diff changeset
     2
 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1090
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "util.h"
24967
582420f5ab6c 8041498: Remove npt library
dsamersoff
parents: 5506
diff changeset
    27
#include "utf_util.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "stream.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "inStream.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "transport.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "bag.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "commonRef.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "FrameID.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#define INITIAL_REF_ALLOC 50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define SMALLEST(a, b) ((a) < (b)) ? (a) : (b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * TO DO: Support processing of replies through command input streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
inStream_init(PacketInputStream *stream, jdwpPacket packet)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    stream->packet = packet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    stream->error = JDWP_ERROR(NONE);
48242
61e60548c0cf 8193258: Better usage of JDWP HEADER SIZE
clanger
parents: 47216
diff changeset
    46
    stream->left = packet.type.cmd.len - JDWP_HEADER_SIZE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    stream->current = packet.type.cmd.data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    stream->refs = bagCreateBag(sizeof(jobject), INITIAL_REF_ALLOC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    if (stream->refs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        stream->error = JDWP_ERROR(OUT_OF_MEMORY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
inStream_id(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    return stream->packet.type.cmd.id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
jbyte
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
inStream_command(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    return stream->packet.type.cmd.cmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
static jdwpError
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
readBytes(PacketInputStream *stream, void *dest, int size)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    if (stream->error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        return stream->error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    if (size > stream->left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        stream->error = JDWP_ERROR(INTERNAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return stream->error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    if (dest) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        (void)memcpy(dest, stream->current, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    stream->current += size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    stream->left -= size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    return stream->error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
jdwpError
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
inStream_skipBytes(PacketInputStream *stream, jint size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    return readBytes(stream, NULL, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
inStream_readBoolean(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    jbyte flag = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    (void)readBytes(stream, &flag, sizeof(flag));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    if (stream->error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        return flag ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
jbyte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
inStream_readByte(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jbyte val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    return val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
jbyte *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
inStream_readBytes(PacketInputStream *stream, int length, jbyte *buf)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    (void)readBytes(stream, buf, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    return buf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
jchar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
inStream_readChar(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    jchar val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    return JAVA_TO_HOST_CHAR(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
jshort
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
inStream_readShort(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    jshort val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    return JAVA_TO_HOST_SHORT(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
inStream_readInt(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    jint val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    return JAVA_TO_HOST_INT(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
inStream_readLong(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    jlong val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    return JAVA_TO_HOST_LONG(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
jfloat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
inStream_readFloat(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    jfloat val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    return JAVA_TO_HOST_FLOAT(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
jdouble
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
inStream_readDouble(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    jdouble val = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    (void)readBytes(stream, &val, sizeof(val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    return JAVA_TO_HOST_DOUBLE(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
/*
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   168
 * Read a module from the stream. The ID used in the wire protocol
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   169
 * is converted to a reference which is returned. The reference is
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   170
 * global and strong, but it should *not* be deleted by the caller
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   171
 * since it is freed when this stream is destroyed.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   172
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   173
jobject
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   174
inStream_readModuleRef(JNIEnv *env, PacketInputStream *stream)
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   175
{
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   176
    jobject ref = inStream_readObjectRef(env, stream);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   177
    if (ref == NULL && stream->error == JDWP_ERROR(INVALID_OBJECT)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   178
        stream->error = JDWP_ERROR(INVALID_MODULE);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   179
        return NULL;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   180
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   181
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   182
    return ref;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   183
}
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   184
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   185
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * Read an object from the stream. The ID used in the wire protocol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * is converted to a reference which is returned. The reference is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * global and strong, but it should *not* be deleted by the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * since it is freed when this stream is destroyed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
jobject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
inStream_readObjectRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    jobject ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    jobject *refPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    jlong id = inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    if (stream->error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    if (id == NULL_OBJECT_ID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    ref = commonRef_idToRef(env, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    if (ref == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        stream->error = JDWP_ERROR(INVALID_OBJECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    refPtr = bagAdd(stream->refs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    if (refPtr == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        commonRef_idToRef_delete(env, ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    *refPtr = ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    return ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * Read a raw object id from the stream. This should be used rarely.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * Normally, inStream_readObjectRef is preferred since it takes care
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * of reference conversion and tracking. Only code that needs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * perform maintence of the commonRef hash table uses this function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
inStream_readObjectID(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    return inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
jclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
inStream_readClassRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    jobject object = inStream_readObjectRef(env, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    if (object == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
         * Could be error or just the null reference. In either case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
         * stop now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    if (!isClass(object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        stream->error = JDWP_ERROR(INVALID_CLASS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
jthread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
inStream_readThreadRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    jobject object = inStream_readObjectRef(env, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    if (object == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         * Could be error or just the null reference. In either case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
         * stop now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    if (!isThread(object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        stream->error = JDWP_ERROR(INVALID_THREAD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
jthreadGroup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
inStream_readThreadGroupRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    jobject object = inStream_readObjectRef(env, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    if (object == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         * Could be error or just the null reference. In either case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         * stop now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    if (!isThreadGroup(object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        stream->error = JDWP_ERROR(INVALID_THREAD_GROUP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
jstring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
inStream_readStringRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    jobject object = inStream_readObjectRef(env, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    if (object == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
         * Could be error or just the null reference. In either case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
         * stop now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    if (!isString(object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        stream->error = JDWP_ERROR(INVALID_STRING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
jclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
inStream_readClassLoaderRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    jobject object = inStream_readObjectRef(env, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    if (object == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
         * Could be error or just the null reference. In either case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
         * stop now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    if (!isClassLoader(object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        stream->error = JDWP_ERROR(INVALID_CLASS_LOADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
jarray
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
inStream_readArrayRef(JNIEnv *env, PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    jobject object = inStream_readObjectRef(env, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    if (object == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
         * Could be error or just the null reference. In either case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
         * stop now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    if (!isArray(object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        stream->error = JDWP_ERROR(INVALID_ARRAY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
 * Next 3 functions read an Int and convert to a Pointer!?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
 * If sizeof(jxxxID) == 8 we must read these values as Longs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
FrameID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
inStream_readFrameID(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    if (sizeof(FrameID) == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return (FrameID)inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        return (FrameID)inStream_readInt(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
jmethodID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
inStream_readMethodID(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    if (sizeof(jmethodID) == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        return (jmethodID)(intptr_t)inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        return (jmethodID)(intptr_t)inStream_readInt(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
jfieldID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
inStream_readFieldID(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    if (sizeof(jfieldID) == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return (jfieldID)(intptr_t)inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        /*LINTED*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        return (jfieldID)(intptr_t)inStream_readInt(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
jlocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
inStream_readLocation(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    return (jlocation)inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
inStream_readString(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    int length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    char *string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    length = inStream_readInt(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    string = jvmtiAllocate(length + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    if (string != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        int new_length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        (void)readBytes(stream, string, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        string[length] = '\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        /* This is Standard UTF-8, convert to Modified UTF-8 if necessary */
24967
582420f5ab6c 8041498: Remove npt library
dsamersoff
parents: 5506
diff changeset
   401
        new_length = utf8sToUtf8mLength((jbyte*)string, length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        if ( new_length != length ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            char *new_string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            new_string = jvmtiAllocate(new_length+1);
24967
582420f5ab6c 8041498: Remove npt library
dsamersoff
parents: 5506
diff changeset
   406
            utf8sToUtf8m((jbyte*)string, length, (jbyte*)new_string, new_length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            jvmtiDeallocate(string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            return new_string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    return string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
jdwpError
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
inStream_error(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    return stream->error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
void
48242
61e60548c0cf 8193258: Better usage of JDWP HEADER SIZE
clanger
parents: 47216
diff changeset
   421
inStream_clearError(PacketInputStream *stream)
61e60548c0cf 8193258: Better usage of JDWP HEADER SIZE
clanger
parents: 47216
diff changeset
   422
{
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    stream->error = JDWP_ERROR(NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
jvalue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
inStream_readValue(PacketInputStream *stream, jbyte *typeKeyPtr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    jvalue value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    jbyte typeKey = inStream_readByte(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    if (stream->error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        value.j = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    if (isObjectTag(typeKey)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        value.l = inStream_readObjectRef(getEnv(), stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        switch (typeKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            case JDWP_TAG(BYTE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                value.b = inStream_readByte(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            case JDWP_TAG(CHAR):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                value.c = inStream_readChar(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            case JDWP_TAG(FLOAT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                value.f = inStream_readFloat(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            case JDWP_TAG(DOUBLE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                value.d = inStream_readDouble(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            case JDWP_TAG(INT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                value.i = inStream_readInt(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            case JDWP_TAG(LONG):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                value.j = inStream_readLong(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            case JDWP_TAG(SHORT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                value.s = inStream_readShort(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            case JDWP_TAG(BOOLEAN):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                value.z = inStream_readBoolean(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                stream->error = JDWP_ERROR(INVALID_TAG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    if (typeKeyPtr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        *typeKeyPtr = typeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
deleteRef(void *elementPtr, void *arg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    JNIEnv *env = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    jobject *refPtr = elementPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    commonRef_idToRef_delete(env, *refPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
inStream_destroy(PacketInputStream *stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    if (stream->packet.type.cmd.data != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    jvmtiDeallocate(stream->packet.type.cmd.data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    (void)bagEnumerateOver(stream->refs, deleteRef, (void *)getEnv());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    bagDestroyBag(stream->refs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
}