Example #1
0
void 
outStream_writeValue(JNIEnv *env, PacketOutputStream *out, 
                     jbyte typeKey, jvalue value)
{
    if (typeKey == JDWP_Tag_OBJECT) {
        outStream_writeByte(out, specificTypeKey(value.l));
    } else {
        outStream_writeByte(out, typeKey);
    }
    if (isObjectTag(typeKey)) {
        WRITE_GLOBAL_REF(env, out, value.l);
    } else {
        switch (typeKey) {
            case JDWP_Tag_BYTE:
                outStream_writeByte(out, value.b);
                break;
    
            case JDWP_Tag_CHAR:
                outStream_writeChar(out, value.c);
                break;
    
            case JDWP_Tag_FLOAT:
                outStream_writeFloat(out, value.f);
                break;
    
            case JDWP_Tag_DOUBLE:
                outStream_writeDouble(out, value.d);
                break;
    
            case JDWP_Tag_INT:
                outStream_writeInt(out, value.i);
                break;
    
            case JDWP_Tag_LONG:
                outStream_writeLong(out, value.j);
                break;
    
            case JDWP_Tag_SHORT:
                outStream_writeShort(out, value.s);
                break;
    
            case JDWP_Tag_BOOLEAN:
                outStream_writeBoolean(out, value.z);
                break;
    
            case JDWP_Tag_VOID:  /* happens with function return values */   
                /* write nothing */
                break;

            default:
                ERROR_MESSAGE_EXIT("Invalid type key");
        }
    }
}
Example #2
0
jint 
outStream_writeFieldID(PacketOutputStream *stream, jfieldID val)
{
    /*
     * Not good - we're writing a pointer as a jint.  Need
     * to write as a jlong if sizeof(jfieldID) == 8.
     */
    if (sizeof(jfieldID) == 8) {
        return outStream_writeLong(stream, (jlong)val);
    } else {
        return outStream_writeInt(stream, (jint)val);
    }
}
Example #3
0
jdwpError 
outStream_writeMethodID(PacketOutputStream *stream, jmethodID val)
{
    /*
     * Not good - we're writing a pointer as a jint.  Need
     * to write as a jlong if sizeof(jmethodID) == 8.
     */
    if (sizeof(jmethodID) == 8) {
        /*LINTED*/
        return outStream_writeLong(stream, (jlong)(intptr_t)val);
    } else {
        /*LINTED*/
        return outStream_writeInt(stream, (jint)(intptr_t)val);
    }
}
Example #4
0
jdwpError 
outStream_writeValue(JNIEnv *env, PacketOutputStream *out, 
                     jbyte typeKey, jvalue value)
{
    if (typeKey == JDWP_TAG(OBJECT)) {
        (void)outStream_writeByte(out, specificTypeKey(env, value.l));
    } else {
        (void)outStream_writeByte(out, typeKey);
    }
    if (isObjectTag(typeKey)) {
        (void)outStream_writeObjectRef(env, out, value.l);
    } else {
        switch (typeKey) {
            case JDWP_TAG(BYTE):
                return outStream_writeByte(out, value.b);
    
            case JDWP_TAG(CHAR):
                return outStream_writeChar(out, value.c);
    
            case JDWP_TAG(FLOAT):
                return outStream_writeFloat(out, value.f);
    
            case JDWP_TAG(DOUBLE):
                return outStream_writeDouble(out, value.d);
    
            case JDWP_TAG(INT):
                return outStream_writeInt(out, value.i);
    
            case JDWP_TAG(LONG):
                return outStream_writeLong(out, value.j);
    
            case JDWP_TAG(SHORT):
                return outStream_writeShort(out, value.s);
    
            case JDWP_TAG(BOOLEAN):
                return outStream_writeBoolean(out, value.z);
    
            case JDWP_TAG(VOID):  /* happens with function return values */   
                /* write nothing */
                return JDWP_ERROR(NONE);

            default:
                EXIT_ERROR(AGENT_ERROR_INVALID_OBJECT,"Invalid type key");
                break;
        }
    }
    return JDWP_ERROR(NONE);
}
Example #5
0
static void
writeLongComponents(JNIEnv *env, PacketOutputStream *out,
                    jarray array, jint index, jint length)
{
    jlong *components;

    components = newComponents(out, length, sizeof(jlong));
    if (components != NULL) {
        jint i;
        JNI_FUNC_PTR(env,GetLongArrayRegion)(env, array, index, length, components);
        for (i = 0; i < length; i++) {
            (void)outStream_writeLong(out, components[i]);
        }
        deleteComponents(components);
    }
}
Example #6
0
static void 
writeMonitorEvent(JNIEnv *env, PacketOutputStream *out, EventInfo *evinfo)
{
    (void)outStream_writeObjectRef(env, out, evinfo->thread);
    (void)outStream_writeObjectTag(env, out, evinfo->object);
    (void)outStream_writeObjectRef(env, out, evinfo->object);
    if (evinfo->ei == EI_MONITOR_WAIT || evinfo->ei == EI_MONITOR_WAITED) {
	/* clazz was set to class of monitor object for monitor wait event class filtering.
	 * See cbMonitorWait() and cbMonitorWaited() function in eventHandler.c. 
	 */
        evinfo->clazz=getMethodClass(gdata->jvmti, evinfo->method);
    }
    writeCodeLocation(out, evinfo->clazz, evinfo->method, evinfo->location);
    if (evinfo->ei == EI_MONITOR_WAIT) {
        (void)outStream_writeLong(out, evinfo->u.monitor.timeout);
    } else  if (evinfo->ei == EI_MONITOR_WAITED) {
        (void)outStream_writeBoolean(out, evinfo->u.monitor.timed_out);
    }
}
Example #7
0
jdwpError 
outStream_writeLocation(PacketOutputStream *stream, jlocation val)
{
    return outStream_writeLong(stream, (jlong)val);
}