Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/demo/jvmti/hprof/hprof_b_spec.h
38829 views
/*1* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* - Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9*10* - Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* - Neither the name of Oracle nor the names of its15* contributors may be used to endorse or promote products derived16* from this software without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS19* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,20* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR22* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,23* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,24* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29*/3031#ifndef HPROF_B_SPEC_H32#define HPROF_B_SPEC_H3334/* Hprof binary format enums and spec. */3536/* Need to #define or typedef HprofId before including this file.37* hprof used ObjectIndex or 4 bytes, but it can be 4 or 8 byte type.38*/3940/* -------------------------------------------------------------------- */41/* -------------------------------------------------------------------- */42/* -------------------------------------------------------------------- */4344/*45* hprof binary format: (result either written to a file or sent over46* the network).47*48* WARNING: This format is still under development, and is subject to49* change without notice.50*51* header "JAVA PROFILE 1.0.1" or "JAVA PROFILE 1.0.2" (0-terminated)52* u4 size of identifiers. Identifiers are used to represent53* UTF8 strings, objects, stack traces, etc. They usually54* have the same size as host pointers. For example, on55* Solaris and Win32, the size is 4.56* u4 high word57* u4 low word number of milliseconds since 0:00 GMT, 1/1/7058* [record]* a sequence of records.59*/6061/*62* Record format:63*64* u1 a TAG denoting the type of the record65* u4 number of *microseconds* since the time stamp in the66* header. (wraps around in a little more than an hour)67* u4 number of bytes *remaining* in the record. Note that68* this number excludes the tag and the length field itself.69* [u1]* BODY of the record (a sequence of bytes)70*/7172/*73* The following TAGs are supported:74*75* TAG BODY notes76*----------------------------------------------------------77* HPROF_UTF8 a UTF8-encoded name78*79* id name ID80* [u1]* UTF8 characters (no trailing zero)81*82* HPROF_LOAD_CLASS a newly loaded class83*84* u4 class serial number (> 0)85* id class object ID86* u4 stack trace serial number87* id class name ID88*89* HPROF_UNLOAD_CLASS an unloading class90*91* u4 class serial_number92*93* HPROF_FRAME a Java stack frame94*95* id stack frame ID96* id method name ID97* id method signature ID98* id source file name ID99* u4 class serial number100* i4 line number. >0: normal101* -1: unknown102* -2: compiled method103* -3: native method104*105* HPROF_TRACE a Java stack trace106*107* u4 stack trace serial number108* u4 thread serial number109* u4 number of frames110* [id]* stack frame IDs111*112*113* HPROF_ALLOC_SITES a set of heap allocation sites, obtained after GC114*115* u2 flags 0x0001: incremental vs. complete116* 0x0002: sorted by allocation vs. live117* 0x0004: whether to force a GC118* u4 cutoff ratio119* u4 total live bytes120* u4 total live instances121* u8 total bytes allocated122* u8 total instances allocated123* u4 number of sites that follow124* [u1 is_array: 0: normal object125* 2: object array126* 4: boolean array127* 5: char array128* 6: float array129* 7: double array130* 8: byte array131* 9: short array132* 10: int array133* 11: long array134* u4 class serial number (may be zero during startup)135* u4 stack trace serial number136* u4 number of bytes alive137* u4 number of instances alive138* u4 number of bytes allocated139* u4]* number of instance allocated140*141* HPROF_START_THREAD a newly started thread.142*143* u4 thread serial number (> 0)144* id thread object ID145* u4 stack trace serial number146* id thread name ID147* id thread group name ID148* id thread group parent name ID149*150* HPROF_END_THREAD a terminating thread.151*152* u4 thread serial number153*154* HPROF_HEAP_SUMMARY heap summary155*156* u4 total live bytes157* u4 total live instances158* u8 total bytes allocated159* u8 total instances allocated160*161* HPROF_HEAP_DUMP or HPROF_HEAP_DUMP_SEGMENT denote a heap dump162*163* [heap dump sub-records]*164*165* There are four kinds of heap dump sub-records:166*167* u1 sub-record type168*169* HPROF_GC_ROOT_UNKNOWN unknown root170*171* id object ID172*173* HPROF_GC_ROOT_THREAD_OBJ thread object174*175* id thread object ID (may be 0 for a176* thread newly attached through JNI)177* u4 thread sequence number178* u4 stack trace sequence number179*180* HPROF_GC_ROOT_JNI_GLOBAL JNI global ref root181*182* id object ID183* id JNI global ref ID184*185* HPROF_GC_ROOT_JNI_LOCAL JNI local ref186*187* id object ID188* u4 thread serial number189* u4 frame # in stack trace (-1 for empty)190*191* HPROF_GC_ROOT_JAVA_FRAME Java stack frame192*193* id object ID194* u4 thread serial number195* u4 frame # in stack trace (-1 for empty)196*197* HPROF_GC_ROOT_NATIVE_STACK Native stack198*199* id object ID200* u4 thread serial number201*202* HPROF_GC_ROOT_STICKY_CLASS System class203*204* id object ID205*206* HPROF_GC_ROOT_THREAD_BLOCK Reference from thread block207*208* id object ID209* u4 thread serial number210*211* HPROF_GC_ROOT_MONITOR_USED Busy monitor212*213* id object ID214*215* HPROF_GC_CLASS_DUMP dump of a class object216*217* id class object ID218* u4 stack trace serial number219* id super class object ID220* id class loader object ID221* id signers object ID222* id protection domain object ID223* id reserved224* id reserved225*226* u4 instance size (in bytes)227*228* u2 size of constant pool229* [u2, constant pool index,230* ty, type231* 2: object232* 4: boolean233* 5: char234* 6: float235* 7: double236* 8: byte237* 9: short238* 10: int239* 11: long240* vl]* and value241*242* u2 number of static fields243* [id, static field name,244* ty, type,245* vl]* and value246*247* u2 number of inst. fields (not inc. super)248* [id, instance field name,249* ty]* type250*251* HPROF_GC_INSTANCE_DUMP dump of a normal object252*253* id object ID254* u4 stack trace serial number255* id class object ID256* u4 number of bytes that follow257* [vl]* instance field values (class, followed258* by super, super's super ...)259*260* HPROF_GC_OBJ_ARRAY_DUMP dump of an object array261*262* id array object ID263* u4 stack trace serial number264* u4 number of elements265* id array class ID266* [id]* elements267*268* HPROF_GC_PRIM_ARRAY_DUMP dump of a primitive array269*270* id array object ID271* u4 stack trace serial number272* u4 number of elements273* u1 element type274* 4: boolean array275* 5: char array276* 6: float array277* 7: double array278* 8: byte array279* 9: short array280* 10: int array281* 11: long array282* [u1]* elements283*284* HPROF_HEAP_DUMP_END terminates series of heap dump segments285*286* HPROF_CPU_SAMPLES a set of sample traces of running threads287*288* u4 total number of samples289* u4 # of traces290* [u4 # of samples291* u4]* stack trace serial number292*293* HPROF_CONTROL_SETTINGS the settings of on/off switches294*295* u4 0x00000001: alloc traces on/off296* 0x00000002: cpu sampling on/off297* u2 stack trace depth298*299*/300301typedef enum HprofTag {302HPROF_UTF8 = 0x01,303HPROF_LOAD_CLASS = 0x02,304HPROF_UNLOAD_CLASS = 0x03,305HPROF_FRAME = 0x04,306HPROF_TRACE = 0x05,307HPROF_ALLOC_SITES = 0x06,308HPROF_HEAP_SUMMARY = 0x07,309HPROF_START_THREAD = 0x0A,310HPROF_END_THREAD = 0x0B,311HPROF_HEAP_DUMP = 0x0C,312HPROF_HEAP_DUMP_SEGMENT = 0x1C, /* 1.0.2 only */313HPROF_HEAP_DUMP_END = 0x2C, /* 1.0.2 only */314HPROF_CPU_SAMPLES = 0x0D,315HPROF_CONTROL_SETTINGS = 0x0E316} HprofTag;317318/*319* Heap dump constants320*/321322typedef enum HprofGcTag {323HPROF_GC_ROOT_UNKNOWN = 0xFF,324HPROF_GC_ROOT_JNI_GLOBAL = 0x01,325HPROF_GC_ROOT_JNI_LOCAL = 0x02,326HPROF_GC_ROOT_JAVA_FRAME = 0x03,327HPROF_GC_ROOT_NATIVE_STACK = 0x04,328HPROF_GC_ROOT_STICKY_CLASS = 0x05,329HPROF_GC_ROOT_THREAD_BLOCK = 0x06,330HPROF_GC_ROOT_MONITOR_USED = 0x07,331HPROF_GC_ROOT_THREAD_OBJ = 0x08,332HPROF_GC_CLASS_DUMP = 0x20,333HPROF_GC_INSTANCE_DUMP = 0x21,334HPROF_GC_OBJ_ARRAY_DUMP = 0x22,335HPROF_GC_PRIM_ARRAY_DUMP = 0x23336} HprofGcTag;337338enum HprofType {339HPROF_ARRAY_OBJECT = 1,340HPROF_NORMAL_OBJECT = 2,341HPROF_BOOLEAN = 4,342HPROF_CHAR = 5,343HPROF_FLOAT = 6,344HPROF_DOUBLE = 7,345HPROF_BYTE = 8,346HPROF_SHORT = 9,347HPROF_INT = 10,348HPROF_LONG = 11349};350typedef unsigned char HprofType;351352#define HPROF_TYPE_SIZES \353{ \354/*Object?*/ sizeof(HprofId), \355/*Object?*/ sizeof(HprofId), \356/*Array*/ sizeof(HprofId), \357/*Object?*/ sizeof(HprofId), \358/*jboolean*/ 1, \359/*jchar*/ 2, \360/*jfloat*/ 4, \361/*jdouble*/ 8, \362/*jbyte*/ 1, \363/*jshort*/ 2, \364/*jint*/ 4, \365/*jlong*/ 8 \366}367368#define HPROF_TYPE_IS_PRIMITIVE(ty) ((ty)>=HPROF_BOOLEAN)369370#endif371372373