Beispiel #1
0
/*
 * Dump some information about an object.
 */
void dvmDumpObject(const Object* obj)
{
    ClassObject* clazz;
    int i;

    if (obj == NULL || obj->clazz == NULL) {
        LOGW("Null or malformed object not dumped\n");
        return;
    }

    clazz = obj->clazz;
    LOGD("----- Object dump: %p (%s, %d bytes) -----\n",
        obj, clazz->descriptor, (int) clazz->objectSize);
    //printHexDump(obj, clazz->objectSize);
    LOGD("  Fields:\n");
    while (clazz != NULL) {
        LOGD("    -- %s\n", clazz->descriptor);
        for (i = 0; i < clazz->ifieldCount; i++) {
            const InstField* pField = &clazz->ifields[i];
            char type = pField->field.signature[0];

            if (type == 'F' || type == 'D') {
                double dval;

                if (type == 'F')
                    dval = dvmGetFieldFloat(obj, pField->byteOffset);
                else
                    dval = dvmGetFieldDouble(obj, pField->byteOffset);

                LOGD("    %2d: '%s' '%s' af=%04x off=%d %.3f\n", i,
                    pField->field.name, pField->field.signature,
                    pField->field.accessFlags, pField->byteOffset, dval);
            } else {
                u8 lval;

                if (type == 'J')
                    lval = dvmGetFieldLong(obj, pField->byteOffset);
                else if (type == 'Z')
                    lval = dvmGetFieldBoolean(obj, pField->byteOffset);
                else
                    lval = dvmGetFieldInt(obj, pField->byteOffset);

                LOGD("    %2d: '%s' '%s' af=%04x off=%d 0x%08llx\n", i,
                    pField->field.name, pField->field.signature,
                    pField->field.accessFlags, pField->byteOffset, lval);
            }
        }

        clazz = clazz->super;
    }
}
Beispiel #2
0
    void ObjTracer::extract_swapTestClass( const Object * const obj )
	{
		fprintf( traceFile_, "instUid %u #%d:  %p\n", 
			opcodeTracer.get_instUid(), TEST_OBJ, obj );

		InstField *pF = &obj->clazz->ifields[6];
		u4 i = dvmGetFieldInt( obj, pF->byteOffset );
		this->record_normal('I', &i );

		pF = &obj->clazz->ifields[4];
		union myunion m;
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u );

		//fprintf(f, "\n");
		fflush(traceFile_);

	}
Beispiel #3
0
	void ObjTracer::extract_location(const Object * const obj)
    	{
		fprintf( traceFile_, "instUid %u #%d:  %p\n", 
			opcodeTracer.get_instUid(), LOCAT_OBJ, obj);

		//longitude
		InstField *pF = &obj->clazz->ifields[6];
		union myunion m;
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u);

		//latitude
		pF = &obj->clazz->ifields[9];
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u);

		//lng2 in cache
		pF = &obj->clazz->ifields[7];
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u);

		//lat2 in cache
		pF = &obj->clazz->ifields[11];
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u);

		//lng1 in cache
		pF = &obj->clazz->ifields[8];
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u);

		//lat1 in cache
		pF = &obj->clazz->ifields[10];
		m.d = dvmGetFieldDouble( obj, pF->byteOffset );
		this->record_normal('D', m.u);

		//provider: GPS or Network
		pF = &obj->clazz->ifields[1];
		Object *o = dvmGetFieldObject ( obj, pF->byteOffset );
		this->extract_str( o );

		//fprintf(f, "\n");
		fflush(traceFile_);
    }
Beispiel #4
0
/*
 * dump一些关于某个对象的信息
 *
 */
void dvmDumpObject(const Object* obj)
{
    ClassObject* clazz;
    int i;

    if (obj == NULL || obj->clazz == NULL) {
        ALOGW("Null or malformed object not dumped");
        return;
    }

    clazz = obj->clazz;
    ALOGD("----- Object dump: %p (%s, %d bytes) -----",
        obj, clazz->descriptor, (int) clazz->objectSize);
    //printHexDump(obj, clazz->objectSize);
    ALOGD("  Fields:");
    while (clazz != NULL) {
        ALOGD("    -- %s", clazz->descriptor);
        for (i = 0; i < clazz->ifieldCount; i++) {
            const InstField* pField = &clazz->ifields[i];
            char type = pField->signature[0];

            if (type == 'F' || type == 'D') {
                double dval;

                if (type == 'F')
                    dval = dvmGetFieldFloat(obj, pField->byteOffset);
                else
                    dval = dvmGetFieldDouble(obj, pField->byteOffset);

                ALOGD("    %2d: '%s' '%s' af=%04x off=%d %.3f", i,
                    pField->name, pField->signature,
                    pField->accessFlags, pField->byteOffset, dval);
            } else {
                u8 lval;

                if (type == 'J')
                    lval = dvmGetFieldLong(obj, pField->byteOffset);
                else if (type == 'Z')
                    lval = dvmGetFieldBoolean(obj, pField->byteOffset);
                else
                    lval = dvmGetFieldInt(obj, pField->byteOffset);

                ALOGD("    %2d: '%s' '%s' af=%04x off=%d 0x%08llx", i,
                    pField->name, pField->signature,
                    pField->accessFlags, pField->byteOffset, lval);
            }
        }

        clazz = clazz->super;
    }
    if (dvmIsClassObject(obj)) {
        ALOGD("  Static fields:");
        const StaticField* sfields = &((ClassObject *)obj)->sfields[0];
        for (i = 0; i < ((ClassObject *)obj)->sfieldCount; ++i) {
            const StaticField* pField = &sfields[i];
            size_t byteOffset = (size_t)pField - (size_t)sfields;
            char type = pField->signature[0];

            if (type == 'F' || type == 'D') {
                double dval;

                if (type == 'F')
                    dval = pField->value.f;
                else
                    dval = pField->value.d;

                ALOGD("    %2d: '%s' '%s' af=%04x off=%zd %.3f", i,
                     pField->name, pField->signature,
                     pField->accessFlags, byteOffset, dval);
            } else {
                u8 lval;

                if (type == 'J')
                    lval = pField->value.j;
                else if (type == 'Z')
                    lval = pField->value.z;
                else
                    lval = pField->value.i;

                ALOGD("    %2d: '%s' '%s' af=%04x off=%zd 0x%08llx", i,
                     pField->name, pField->signature,
                     pField->accessFlags, byteOffset, lval);
            }
        }
    }
}