// An attribute to place on a parameter to a function, for example: // int foo(int x ATTRIBUTE_UNUSED) { return 10; } // to avoid compiler warnings. #define ATTRIBUTE_UNUSED __attribute__((__unused__))
/* *ComputethelengthofaHPROF_CLASS_DUMPblock.
*/ staticint computeClassDumpLen(constunsignedchar* origBuf, int len)
{ constunsignedchar* buf = origBuf; int blockLen = 0; int i, count;
/* *ComputethelengthofaHPROF_INSTANCE_DUMPblock.
*/ staticint computeInstanceDumpLen(constunsignedchar* origBuf, int len ATTRIBUTE_UNUSED)
{ int extraCount = get4BE(origBuf + kIdentSize * 2 + 4); return kIdentSize * 2 + 8 + extraCount;
}
/* *ComputethelengthofaHPROF_OBJECT_ARRAY_DUMPblock.
*/ staticint computeObjectArrayDumpLen(constunsignedchar* origBuf, int len ATTRIBUTE_UNUSED)
{ int arrayCount = get4BE(origBuf + kIdentSize + 4); return kIdentSize * 2 + 8 + arrayCount * kIdentSize;
}
/* *ComputethelengthofaHPROF_PRIMITIVE_ARRAY_DUMPblock.
*/ staticint computePrimitiveArrayDumpLen(constunsignedchar* origBuf, int len ATTRIBUTE_UNUSED)
{ int arrayCount = get4BE(origBuf + kIdentSize + 4);
HprofBasicType basicType = origBuf[kIdentSize + 8]; int basicLen = computeBasicLen(basicType);
return kIdentSize + 9 + arrayCount * basicLen;
}
/* *Crunchthroughaheapdumprecord,writingtheoriginalorconverted *datato"out".
*/ staticint processHeapDump(ExpandBuf* pBuf, FILE* out, int flags)
{
ExpandBuf* pOutBuf = ebAlloc(); unsignedchar* origBuf = ebGetBuffer(pBuf); unsignedchar* buf = origBuf; int len = ebGetLength(pBuf); int result = -1; int heapType = HPROF_HEAP_DEFAULT; int heapIgnore = FALSE;
pBuf = NULL; /* we just use the raw pointer from here forward */
/* copy the original header to the output buffer */ if (ebAddData(pOutBuf, buf, kRecHdrLen) != 0) goto bail;
buf += kRecHdrLen; /* skip past record header */
len -= kRecHdrLen;
while (len > 0) { unsignedchar subType = buf[0]; int justCopy = TRUE; int subLen;
DBUG("--- 0x%02x ", subType); switch (subType) { /* 1.0.2 types */ case HPROF_ROOT_UNKNOWN:
subLen = kIdentSize; break; case HPROF_ROOT_JNI_GLOBAL:
subLen = kIdentSize * 2; break; case HPROF_ROOT_JNI_LOCAL:
subLen = kIdentSize + 8; break; case HPROF_ROOT_JAVA_FRAME:
subLen = kIdentSize + 8; break; case HPROF_ROOT_NATIVE_STACK:
subLen = kIdentSize + 4; break; case HPROF_ROOT_STICKY_CLASS:
subLen = kIdentSize; break; case HPROF_ROOT_THREAD_BLOCK:
subLen = kIdentSize + 4; break; case HPROF_ROOT_MONITOR_USED:
subLen = kIdentSize; break; case HPROF_ROOT_THREAD_OBJECT:
subLen = kIdentSize + 8; break; case HPROF_CLASS_DUMP:
subLen = computeClassDumpLen(buf+1, len-1); break; case HPROF_INSTANCE_DUMP:
subLen = computeInstanceDumpLen(buf+1, len-1); if (heapIgnore) {
justCopy = FALSE;
} break; case HPROF_OBJECT_ARRAY_DUMP:
subLen = computeObjectArrayDumpLen(buf+1, len-1); if (heapIgnore) {
justCopy = FALSE;
} break; case HPROF_PRIMITIVE_ARRAY_DUMP:
subLen = computePrimitiveArrayDumpLen(buf+1, len-1); if (heapIgnore) {
justCopy = FALSE;
} break; /* these were added for Android in 1.0.3 */ case HPROF_HEAP_DUMP_INFO:
heapType = get4BE(buf+1); if ((flags & kFlagAppOnly) != 0
&& (heapType == HPROF_HEAP_ZYGOTE || heapType == HPROF_HEAP_IMAGE)) {
heapIgnore = TRUE;
} else {
heapIgnore = FALSE;
}
justCopy = FALSE;
subLen = kIdentSize + 4; // no 1.0.2 equivalent for this break; case HPROF_ROOT_INTERNED_STRING:
buf[0] = HPROF_ROOT_UNKNOWN;
subLen = kIdentSize; break; case HPROF_ROOT_FINALIZING:
buf[0] = HPROF_ROOT_UNKNOWN;
subLen = kIdentSize; break; case HPROF_ROOT_DEBUGGER:
buf[0] = HPROF_ROOT_UNKNOWN;
subLen = kIdentSize; break; case HPROF_ROOT_REFERENCE_CLEANUP:
buf[0] = HPROF_ROOT_UNKNOWN;
subLen = kIdentSize; break; case HPROF_ROOT_VM_INTERNAL:
buf[0] = HPROF_ROOT_UNKNOWN;
subLen = kIdentSize; break; case HPROF_ROOT_JNI_MONITOR: /* keep the ident, drop the next 8 bytes */
buf[0] = HPROF_ROOT_UNKNOWN;
justCopy = FALSE;
ebAddData(pOutBuf, buf, 1 + kIdentSize);
subLen = kIdentSize + 8; break; case HPROF_UNREACHABLE:
buf[0] = HPROF_ROOT_UNKNOWN;
subLen = kIdentSize; break; case HPROF_PRIMITIVE_ARRAY_NODATA_DUMP:
buf[0] = HPROF_PRIMITIVE_ARRAY_DUMP;
buf[5] = buf[6] = buf[7] = buf[8] = 0; /* set array len to 0 */
subLen = kIdentSize + 9; break;
/* shouldn't get here */ default:
fprintf(stderr, "ERROR: unexpected subtype 0x%02x at offset %zu\n",
subType, (size_t) (buf - origBuf)); goto bail;
}
if (justCopy) { /* copy source data */
DBUG("(%d)\n", 1 + subLen);
ebAddData(pOutBuf, buf, 1 + subLen);
} else { /* other data has been written, or the sub-record omitted */
DBUG("(adv %d)\n", 1 + subLen);
}
/* advance to next entry */
buf += 1 + subLen;
len -= 1 + subLen;
}
int i; for (i = optind; i < argc; i++) { char* arg = argv[i]; if (!in) {
in = fopen_or_default(arg, "rb", stdin);
} elseif (!out) {
out = fopen_or_default(arg, "wb", stdout);
} else { goto usage;
}
}
if (in == NULL || out == NULL) { goto usage;
}
res = filterData(in, out, flags); goto finish;
usage:
fprintf(stderr, "Usage: hprof-conf [-z] infile outfile\n");
fprintf(stderr, "\n");
fprintf(stderr, " -z: exclude non-app heaps, such as Zygote\n");
fprintf(stderr, "\n");
fprintf(stderr, "Specify '-' for either or both files to use stdin/stdout.\n");
fprintf(stderr, "\n");
fprintf(stderr, "Copyright (C) 2009 The Android Open Source Project\n\n" "This software is built from source code licensed under the " "Apache License,\n" "Version 2.0 (the \"License\"). You may obtain a copy of the " "License at\n\n" " http://www.apache.org/licenses/LICENSE-2.0\n\n" "See the associated NOTICE file for this software for further " "details.\n");
res = 2;
finish: if (in != stdin && in != NULL)
fclose(in); if (out != stdout && out != NULL)
fclose(out); return res;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.