0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A *
0N/A * Redistribution and use in source and binary forms, with or without
0N/A * modification, are permitted provided that the following conditions
0N/A * are met:
0N/A *
0N/A * - Redistributions of source code must retain the above copyright
0N/A * notice, this list of conditions and the following disclaimer.
0N/A *
0N/A * - Redistributions in binary form must reproduce the above copyright
0N/A * notice, this list of conditions and the following disclaimer in the
0N/A * documentation and/or other materials provided with the distribution.
0N/A *
2362N/A * - Neither the name of Oracle nor the names of its
0N/A * contributors may be used to endorse or promote products derived
0N/A * from this software without specific prior written permission.
0N/A *
0N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
0N/A * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
0N/A * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0N/A * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0N/A * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0N/A */
0N/A
0N/A#ifndef HPROF_B_SPEC_H
0N/A#define HPROF_B_SPEC_H
0N/A
0N/A/* Hprof binary format enums and spec. */
0N/A
0N/A/* Need to #define or typedef HprofId before including this file.
0N/A * hprof used ObjectIndex or 4 bytes, but it can be 4 or 8 byte type.
0N/A */
0N/A
0N/A/* -------------------------------------------------------------------- */
0N/A/* -------------------------------------------------------------------- */
0N/A/* -------------------------------------------------------------------- */
0N/A
0N/A/*
0N/A * hprof binary format: (result either written to a file or sent over
0N/A * the network).
0N/A *
0N/A * WARNING: This format is still under development, and is subject to
0N/A * change without notice.
0N/A *
0N/A * header "JAVA PROFILE 1.0.1" or "JAVA PROFILE 1.0.2" (0-terminated)
0N/A * u4 size of identifiers. Identifiers are used to represent
0N/A * UTF8 strings, objects, stack traces, etc. They usually
0N/A * have the same size as host pointers. For example, on
0N/A * Solaris and Win32, the size is 4.
0N/A * u4 high word
0N/A * u4 low word number of milliseconds since 0:00 GMT, 1/1/70
0N/A * [record]* a sequence of records.
0N/A */
0N/A
0N/A/*
0N/A * Record format:
0N/A *
0N/A * u1 a TAG denoting the type of the record
0N/A * u4 number of *microseconds* since the time stamp in the
0N/A * header. (wraps around in a little more than an hour)
0N/A * u4 number of bytes *remaining* in the record. Note that
0N/A * this number excludes the tag and the length field itself.
0N/A * [u1]* BODY of the record (a sequence of bytes)
0N/A */
0N/A
0N/A/*
0N/A * The following TAGs are supported:
0N/A *
0N/A * TAG BODY notes
0N/A *----------------------------------------------------------
0N/A * HPROF_UTF8 a UTF8-encoded name
0N/A *
0N/A * id name ID
0N/A * [u1]* UTF8 characters (no trailing zero)
0N/A *
0N/A * HPROF_LOAD_CLASS a newly loaded class
0N/A *
0N/A * u4 class serial number (> 0)
0N/A * id class object ID
0N/A * u4 stack trace serial number
0N/A * id class name ID
0N/A *
0N/A * HPROF_UNLOAD_CLASS an unloading class
0N/A *
0N/A * u4 class serial_number
0N/A *
0N/A * HPROF_FRAME a Java stack frame
0N/A *
0N/A * id stack frame ID
0N/A * id method name ID
0N/A * id method signature ID
0N/A * id source file name ID
0N/A * u4 class serial number
0N/A * i4 line number. >0: normal
0N/A * -1: unknown
0N/A * -2: compiled method
0N/A * -3: native method
0N/A *
0N/A * HPROF_TRACE a Java stack trace
0N/A *
0N/A * u4 stack trace serial number
0N/A * u4 thread serial number
0N/A * u4 number of frames
0N/A * [id]* stack frame IDs
0N/A *
0N/A *
0N/A * HPROF_ALLOC_SITES a set of heap allocation sites, obtained after GC
0N/A *
0N/A * u2 flags 0x0001: incremental vs. complete
0N/A * 0x0002: sorted by allocation vs. live
0N/A * 0x0004: whether to force a GC
0N/A * u4 cutoff ratio
0N/A * u4 total live bytes
0N/A * u4 total live instances
0N/A * u8 total bytes allocated
0N/A * u8 total instances allocated
0N/A * u4 number of sites that follow
0N/A * [u1 is_array: 0: normal object
0N/A * 2: object array
0N/A * 4: boolean array
0N/A * 5: char array
0N/A * 6: float array
0N/A * 7: double array
0N/A * 8: byte array
0N/A * 9: short array
0N/A * 10: int array
0N/A * 11: long array
0N/A * u4 class serial number (may be zero during startup)
0N/A * u4 stack trace serial number
0N/A * u4 number of bytes alive
0N/A * u4 number of instances alive
0N/A * u4 number of bytes allocated
0N/A * u4]* number of instance allocated
0N/A *
0N/A * HPROF_START_THREAD a newly started thread.
0N/A *
0N/A * u4 thread serial number (> 0)
0N/A * id thread object ID
0N/A * u4 stack trace serial number
0N/A * id thread name ID
0N/A * id thread group name ID
0N/A * id thread group parent name ID
0N/A *
0N/A * HPROF_END_THREAD a terminating thread.
0N/A *
0N/A * u4 thread serial number
0N/A *
0N/A * HPROF_HEAP_SUMMARY heap summary
0N/A *
0N/A * u4 total live bytes
0N/A * u4 total live instances
0N/A * u8 total bytes allocated
0N/A * u8 total instances allocated
0N/A *
0N/A * HPROF_HEAP_DUMP or HPROF_HEAP_DUMP_SEGMENT denote a heap dump
0N/A *
0N/A * [heap dump sub-records]*
0N/A *
0N/A * There are four kinds of heap dump sub-records:
0N/A *
0N/A * u1 sub-record type
0N/A *
0N/A * HPROF_GC_ROOT_UNKNOWN unknown root
0N/A *
0N/A * id object ID
0N/A *
0N/A * HPROF_GC_ROOT_THREAD_OBJ thread object
0N/A *
0N/A * id thread object ID (may be 0 for a
0N/A * thread newly attached through JNI)
0N/A * u4 thread sequence number
0N/A * u4 stack trace sequence number
0N/A *
0N/A * HPROF_GC_ROOT_JNI_GLOBAL JNI global ref root
0N/A *
0N/A * id object ID
0N/A * id JNI global ref ID
0N/A *
0N/A * HPROF_GC_ROOT_JNI_LOCAL JNI local ref
0N/A *
0N/A * id object ID
0N/A * u4 thread serial number
0N/A * u4 frame # in stack trace (-1 for empty)
0N/A *
0N/A * HPROF_GC_ROOT_JAVA_FRAME Java stack frame
0N/A *
0N/A * id object ID
0N/A * u4 thread serial number
0N/A * u4 frame # in stack trace (-1 for empty)
0N/A *
0N/A * HPROF_GC_ROOT_NATIVE_STACK Native stack
0N/A *
0N/A * id object ID
0N/A * u4 thread serial number
0N/A *
0N/A * HPROF_GC_ROOT_STICKY_CLASS System class
0N/A *
0N/A * id object ID
0N/A *
0N/A * HPROF_GC_ROOT_THREAD_BLOCK Reference from thread block
0N/A *
0N/A * id object ID
0N/A * u4 thread serial number
0N/A *
0N/A * HPROF_GC_ROOT_MONITOR_USED Busy monitor
0N/A *
0N/A * id object ID
0N/A *
0N/A * HPROF_GC_CLASS_DUMP dump of a class object
0N/A *
0N/A * id class object ID
0N/A * u4 stack trace serial number
0N/A * id super class object ID
0N/A * id class loader object ID
0N/A * id signers object ID
0N/A * id protection domain object ID
0N/A * id reserved
0N/A * id reserved
0N/A *
0N/A * u4 instance size (in bytes)
0N/A *
0N/A * u2 size of constant pool
0N/A * [u2, constant pool index,
0N/A * ty, type
0N/A * 2: object
0N/A * 4: boolean
0N/A * 5: char
0N/A * 6: float
0N/A * 7: double
0N/A * 8: byte
0N/A * 9: short
0N/A * 10: int
0N/A * 11: long
0N/A * vl]* and value
0N/A *
0N/A * u2 number of static fields
0N/A * [id, static field name,
0N/A * ty, type,
0N/A * vl]* and value
0N/A *
0N/A * u2 number of inst. fields (not inc. super)
0N/A * [id, instance field name,
0N/A * ty]* type
0N/A *
0N/A * HPROF_GC_INSTANCE_DUMP dump of a normal object
0N/A *
0N/A * id object ID
0N/A * u4 stack trace serial number
0N/A * id class object ID
0N/A * u4 number of bytes that follow
0N/A * [vl]* instance field values (class, followed
0N/A * by super, super's super ...)
0N/A *
0N/A * HPROF_GC_OBJ_ARRAY_DUMP dump of an object array
0N/A *
0N/A * id array object ID
0N/A * u4 stack trace serial number
0N/A * u4 number of elements
0N/A * id array class ID
0N/A * [id]* elements
0N/A *
0N/A * HPROF_GC_PRIM_ARRAY_DUMP dump of a primitive array
0N/A *
0N/A * id array object ID
0N/A * u4 stack trace serial number
0N/A * u4 number of elements
0N/A * u1 element type
0N/A * 4: boolean array
0N/A * 5: char array
0N/A * 6: float array
0N/A * 7: double array
0N/A * 8: byte array
0N/A * 9: short array
0N/A * 10: int array
0N/A * 11: long array
0N/A * [u1]* elements
0N/A *
0N/A * HPROF_HEAP_DUMP_END terminates series of heap dump segments
0N/A *
0N/A * HPROF_CPU_SAMPLES a set of sample traces of running threads
0N/A *
0N/A * u4 total number of samples
0N/A * u4 # of traces
0N/A * [u4 # of samples
0N/A * u4]* stack trace serial number
0N/A *
0N/A * HPROF_CONTROL_SETTINGS the settings of on/off switches
0N/A *
0N/A * u4 0x00000001: alloc traces on/off
0N/A * 0x00000002: cpu sampling on/off
0N/A * u2 stack trace depth
0N/A *
0N/A */
0N/A
0N/Atypedef enum HprofTag {
0N/A HPROF_UTF8 = 0x01,
0N/A HPROF_LOAD_CLASS = 0x02,
0N/A HPROF_UNLOAD_CLASS = 0x03,
0N/A HPROF_FRAME = 0x04,
0N/A HPROF_TRACE = 0x05,
0N/A HPROF_ALLOC_SITES = 0x06,
0N/A HPROF_HEAP_SUMMARY = 0x07,
0N/A HPROF_START_THREAD = 0x0A,
0N/A HPROF_END_THREAD = 0x0B,
0N/A HPROF_HEAP_DUMP = 0x0C,
0N/A HPROF_HEAP_DUMP_SEGMENT = 0x1C, /* 1.0.2 only */
0N/A HPROF_HEAP_DUMP_END = 0x2C, /* 1.0.2 only */
0N/A HPROF_CPU_SAMPLES = 0x0D,
0N/A HPROF_CONTROL_SETTINGS = 0x0E
0N/A} HprofTag;
0N/A
0N/A/*
0N/A * Heap dump constants
0N/A */
0N/A
0N/Atypedef enum HprofGcTag {
0N/A HPROF_GC_ROOT_UNKNOWN = 0xFF,
0N/A HPROF_GC_ROOT_JNI_GLOBAL = 0x01,
0N/A HPROF_GC_ROOT_JNI_LOCAL = 0x02,
0N/A HPROF_GC_ROOT_JAVA_FRAME = 0x03,
0N/A HPROF_GC_ROOT_NATIVE_STACK = 0x04,
0N/A HPROF_GC_ROOT_STICKY_CLASS = 0x05,
0N/A HPROF_GC_ROOT_THREAD_BLOCK = 0x06,
0N/A HPROF_GC_ROOT_MONITOR_USED = 0x07,
0N/A HPROF_GC_ROOT_THREAD_OBJ = 0x08,
0N/A HPROF_GC_CLASS_DUMP = 0x20,
0N/A HPROF_GC_INSTANCE_DUMP = 0x21,
0N/A HPROF_GC_OBJ_ARRAY_DUMP = 0x22,
0N/A HPROF_GC_PRIM_ARRAY_DUMP = 0x23
0N/A} HprofGcTag;
0N/A
0N/Aenum HprofType {
0N/A HPROF_ARRAY_OBJECT = 1,
0N/A HPROF_NORMAL_OBJECT = 2,
0N/A HPROF_BOOLEAN = 4,
0N/A HPROF_CHAR = 5,
0N/A HPROF_FLOAT = 6,
0N/A HPROF_DOUBLE = 7,
0N/A HPROF_BYTE = 8,
0N/A HPROF_SHORT = 9,
0N/A HPROF_INT = 10,
0N/A HPROF_LONG = 11
0N/A};
0N/Atypedef unsigned char HprofType;
0N/A
0N/A#define HPROF_TYPE_SIZES \
0N/A { \
0N/A /*Object?*/ sizeof(HprofId), \
0N/A /*Object?*/ sizeof(HprofId), \
0N/A /*Array*/ sizeof(HprofId), \
0N/A /*Object?*/ sizeof(HprofId), \
0N/A /*jboolean*/ 1, \
0N/A /*jchar*/ 2, \
0N/A /*jfloat*/ 4, \
0N/A /*jdouble*/ 8, \
0N/A /*jbyte*/ 1, \
0N/A /*jshort*/ 2, \
0N/A /*jint*/ 4, \
0N/A /*jlong*/ 8 \
0N/A }
0N/A
0N/A#define HPROF_TYPE_IS_PRIMITIVE(ty) ((ty)>=HPROF_BOOLEAN)
0N/A
0N/A#endif