src/jdk.jdwp.agent/share/native/libjdwp/ObjectReferenceImpl.c
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2005, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "ObjectReferenceImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "commonRef.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "inStream.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "outStream.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
referenceType(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    jobject object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    object = inStream_readObjectRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        jbyte tag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        clazz = JNI_FUNC_PTR(env,GetObjectClass)(env, object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        tag = referenceTypeTag(clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        (void)outStream_writeByte(out, tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        (void)outStream_writeObjectRef(env, out, clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
getValues(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    sharedGetFieldValues(in, out, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
static jvmtiError
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
readFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
               jobject object, jfieldID field, char *signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    jvalue value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    switch (signature[0]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        case JDWP_TAG(ARRAY):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        case JDWP_TAG(OBJECT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            value.l = inStream_readObjectRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            JNI_FUNC_PTR(env,SetObjectField)(env, object, field, value.l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        case JDWP_TAG(BYTE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            value.b = inStream_readByte(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            JNI_FUNC_PTR(env,SetByteField)(env, object, field, value.b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        case JDWP_TAG(CHAR):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            value.c = inStream_readChar(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            JNI_FUNC_PTR(env,SetCharField)(env, object, field, value.c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        case JDWP_TAG(FLOAT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            value.f = inStream_readFloat(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            JNI_FUNC_PTR(env,SetFloatField)(env, object, field, value.f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        case JDWP_TAG(DOUBLE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            value.d = inStream_readDouble(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            JNI_FUNC_PTR(env,SetDoubleField)(env, object, field, value.d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        case JDWP_TAG(INT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            value.i = inStream_readInt(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            JNI_FUNC_PTR(env,SetIntField)(env, object, field, value.i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        case JDWP_TAG(LONG):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            value.j = inStream_readLong(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            JNI_FUNC_PTR(env,SetLongField)(env, object, field, value.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        case JDWP_TAG(SHORT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            value.s = inStream_readShort(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            JNI_FUNC_PTR(env,SetShortField)(env, object, field, value.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        case JDWP_TAG(BOOLEAN):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            value.z = inStream_readBoolean(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            JNI_FUNC_PTR(env,SetBooleanField)(env, object, field, value.z);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    error = JVMTI_ERROR_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        error = AGENT_ERROR_JNI_EXCEPTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    return error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
setValues(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    jint count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    jobject object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    object = inStream_readObjectRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    count = inStream_readInt(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    error = JVMTI_ERROR_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    WITH_LOCAL_REFS(env, count + 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        clazz = JNI_FUNC_PTR(env,GetObjectClass)(env, object);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (clazz != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            for (i = 0; (i < count) && !inStream_error(in); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                jfieldID field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                char *signature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                field = inStream_readFieldID(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                if (inStream_error(in))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                error = fieldSignature(clazz, field, NULL, &signature, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                error = readFieldValue(env, in, clazz, object, field, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                jvmtiDeallocate(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
monitorInfo(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    jobject object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    object = inStream_readObjectRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        jvmtiMonitorUsage info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        (void)memset(&info, 0, sizeof(info));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        error = JVMTI_FUNC_PTR(gdata->jvmti,GetObjectMonitorUsage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                        (gdata->jvmti, object, &info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            (void)outStream_writeObjectRef(env, out, info.owner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            (void)outStream_writeInt(out, info.entry_count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            (void)outStream_writeInt(out, info.waiter_count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            for (i = 0; i < info.waiter_count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                (void)outStream_writeObjectRef(env, out, info.waiters[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        if (info.waiters != NULL )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            jvmtiDeallocate(info.waiters);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
invokeInstance(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    return sharedInvoke(in, out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
disableCollection(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    jlong id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    id = inStream_readObjectID(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    error = commonRef_pin(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
enableCollection(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    jlong id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    id = inStream_readObjectID(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    error = commonRef_unpin(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
isCollected(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    jobject ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    jlong id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    id = inStream_readObjectID(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    if (id == NULL_OBJECT_ID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        outStream_setError(out, JDWP_ERROR(INVALID_OBJECT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    ref = commonRef_idToRef(env, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    (void)outStream_writeBoolean(out, (jboolean)(ref == NULL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    commonRef_idToRef_delete(env, ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
referringObjects(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    jobject object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    jint    maxReferrers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    if (gdata->vmDead) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        outStream_setError(out, JDWP_ERROR(VM_DEAD));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    object = inStream_readObjectRef(env,in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    maxReferrers = inStream_readInt(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        jvmtiError   error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        ObjectBatch  referrerBatch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        error = objectReferrers(object, &referrerBatch, maxReferrers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            int kk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            (void)outStream_writeInt(out, referrerBatch.count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            for (kk = 0; kk < referrerBatch.count; kk++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                jobject ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                ref = referrerBatch.objects[kk];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                (void)outStream_writeByte(out, specificTypeKey(env, ref));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                (void)outStream_writeObjectRef(env, out, ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            jvmtiDeallocate(referrerBatch.objects);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
void *ObjectReference_Cmds[] = { (void *)10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    ,(void *)referenceType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    ,(void *)getValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    ,(void *)setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    ,(void *)NULL      /* no longer used */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    ,(void *)monitorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    ,(void *)invokeInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    ,(void *)disableCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    ,(void *)enableCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    ,(void *)isCollected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    ,(void *)referringObjects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    };