00001 /* 00002 * @(#)hprof_b_spec.h 1.6 10/03/23 00003 * 00004 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * 00009 * -Redistribution of source code must retain the above copyright notice, this 00010 * list of conditions and the following disclaimer. 00011 * 00012 * -Redistribution in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * 00016 * Neither the name of Oracle or the names of contributors may 00017 * be used to endorse or promote products derived from this software without 00018 * specific prior written permission. 00019 * 00020 * This software is provided "AS IS," without a warranty of any kind. ALL 00021 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING 00022 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00023 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") 00024 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE 00025 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS 00026 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST 00027 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, 00028 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY 00029 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, 00030 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00031 * 00032 * You acknowledge that this software is not designed, licensed or intended 00033 * for use in the design, construction, operation or maintenance of any 00034 * nuclear facility. 00035 */ 00036 00037 #ifndef HPROF_B_SPEC_H 00038 #define HPROF_B_SPEC_H 00039 00040 /* Hprof binary format enums and spec. */ 00041 00042 /* Need to #define or typedef HprofId before including this file. 00043 * hprof used ObjectIndex or 4 bytes, but it can be 4 or 8 byte type. 00044 */ 00045 00046 /* -------------------------------------------------------------------- */ 00047 /* -------------------------------------------------------------------- */ 00048 /* -------------------------------------------------------------------- */ 00049 00050 /* 00051 * hprof binary format: (result either written to a file or sent over 00052 * the network). 00053 * 00054 * WARNING: This format is still under development, and is subject to 00055 * change without notice. 00056 * 00057 * header "JAVA PROFILE 1.0.1" or "JAVA PROFILE 1.0.2" (0-terminated) 00058 * u4 size of identifiers. Identifiers are used to represent 00059 * UTF8 strings, objects, stack traces, etc. They usually 00060 * have the same size as host pointers. For example, on 00061 * Solaris and Win32, the size is 4. 00062 * u4 high word 00063 * u4 low word number of milliseconds since 0:00 GMT, 1/1/70 00064 * [record]* a sequence of records. 00065 */ 00066 00067 /* 00068 * Record format: 00069 * 00070 * u1 a TAG denoting the type of the record 00071 * u4 number of *microseconds* since the time stamp in the 00072 * header. (wraps around in a little more than an hour) 00073 * u4 number of bytes *remaining* in the record. Note that 00074 * this number excludes the tag and the length field itself. 00075 * [u1]* BODY of the record (a sequence of bytes) 00076 */ 00077 00078 /* 00079 * The following TAGs are supported: 00080 * 00081 * TAG BODY notes 00082 *---------------------------------------------------------- 00083 * HPROF_UTF8 a UTF8-encoded name 00084 * 00085 * id name ID 00086 * [u1]* UTF8 characters (no trailing zero) 00087 * 00088 * HPROF_LOAD_CLASS a newly loaded class 00089 * 00090 * u4 class serial number (> 0) 00091 * id class object ID 00092 * u4 stack trace serial number 00093 * id class name ID 00094 * 00095 * HPROF_UNLOAD_CLASS an unloading class 00096 * 00097 * u4 class serial_number 00098 * 00099 * HPROF_FRAME a Java stack frame 00100 * 00101 * id stack frame ID 00102 * id method name ID 00103 * id method signature ID 00104 * id source file name ID 00105 * u4 class serial number 00106 * i4 line number. >0: normal 00107 * -1: unknown 00108 * -2: compiled method 00109 * -3: native method 00110 * 00111 * HPROF_TRACE a Java stack trace 00112 * 00113 * u4 stack trace serial number 00114 * u4 thread serial number 00115 * u4 number of frames 00116 * [id]* stack frame IDs 00117 * 00118 * 00119 * HPROF_ALLOC_SITES a set of heap allocation sites, obtained after GC 00120 * 00121 * u2 flags 0x0001: incremental vs. complete 00122 * 0x0002: sorted by allocation vs. live 00123 * 0x0004: whether to force a GC 00124 * u4 cutoff ratio 00125 * u4 total live bytes 00126 * u4 total live instances 00127 * u8 total bytes allocated 00128 * u8 total instances allocated 00129 * u4 number of sites that follow 00130 * [u1 is_array: 0: normal object 00131 * 2: object array 00132 * 4: boolean array 00133 * 5: char array 00134 * 6: float array 00135 * 7: double array 00136 * 8: byte array 00137 * 9: short array 00138 * 10: int array 00139 * 11: long array 00140 * u4 class serial number (may be zero during startup) 00141 * u4 stack trace serial number 00142 * u4 number of bytes alive 00143 * u4 number of instances alive 00144 * u4 number of bytes allocated 00145 * u4]* number of instance allocated 00146 * 00147 * HPROF_START_THREAD a newly started thread. 00148 * 00149 * u4 thread serial number (> 0) 00150 * id thread object ID 00151 * u4 stack trace serial number 00152 * id thread name ID 00153 * id thread group name ID 00154 * id thread group parent name ID 00155 * 00156 * HPROF_END_THREAD a terminating thread. 00157 * 00158 * u4 thread serial number 00159 * 00160 * HPROF_HEAP_SUMMARY heap summary 00161 * 00162 * u4 total live bytes 00163 * u4 total live instances 00164 * u8 total bytes allocated 00165 * u8 total instances allocated 00166 * 00167 * HPROF_HEAP_DUMP or HPROF_HEAP_DUMP_SEGMENT denote a heap dump 00168 * 00169 * [heap dump sub-records]* 00170 * 00171 * There are four kinds of heap dump sub-records: 00172 * 00173 * u1 sub-record type 00174 * 00175 * HPROF_GC_ROOT_UNKNOWN unknown root 00176 * 00177 * id object ID 00178 * 00179 * HPROF_GC_ROOT_THREAD_OBJ thread object 00180 * 00181 * id thread object ID (may be 0 for a 00182 * thread newly attached through JNI) 00183 * u4 thread sequence number 00184 * u4 stack trace sequence number 00185 * 00186 * HPROF_GC_ROOT_JNI_GLOBAL JNI global ref root 00187 * 00188 * id object ID 00189 * id JNI global ref ID 00190 * 00191 * HPROF_GC_ROOT_JNI_LOCAL JNI local ref 00192 * 00193 * id object ID 00194 * u4 thread serial number 00195 * u4 frame # in stack trace (-1 for empty) 00196 * 00197 * HPROF_GC_ROOT_JAVA_FRAME Java stack frame 00198 * 00199 * id object ID 00200 * u4 thread serial number 00201 * u4 frame # in stack trace (-1 for empty) 00202 * 00203 * HPROF_GC_ROOT_NATIVE_STACK Native stack 00204 * 00205 * id object ID 00206 * u4 thread serial number 00207 * 00208 * HPROF_GC_ROOT_STICKY_CLASS System class 00209 * 00210 * id object ID 00211 * 00212 * HPROF_GC_ROOT_THREAD_BLOCK Reference from thread block 00213 * 00214 * id object ID 00215 * u4 thread serial number 00216 * 00217 * HPROF_GC_ROOT_MONITOR_USED Busy monitor 00218 * 00219 * id object ID 00220 * 00221 * HPROF_GC_CLASS_DUMP dump of a class object 00222 * 00223 * id class object ID 00224 * u4 stack trace serial number 00225 * id super class object ID 00226 * id class loader object ID 00227 * id signers object ID 00228 * id protection domain object ID 00229 * id reserved 00230 * id reserved 00231 * 00232 * u4 instance size (in bytes) 00233 * 00234 * u2 size of constant pool 00235 * [u2, constant pool index, 00236 * ty, type 00237 * 2: object 00238 * 4: boolean 00239 * 5: char 00240 * 6: float 00241 * 7: double 00242 * 8: byte 00243 * 9: short 00244 * 10: int 00245 * 11: long 00246 * vl]* and value 00247 * 00248 * u2 number of static fields 00249 * [id, static field name, 00250 * ty, type, 00251 * vl]* and value 00252 * 00253 * u2 number of inst. fields (not inc. super) 00254 * [id, instance field name, 00255 * ty]* type 00256 * 00257 * HPROF_GC_INSTANCE_DUMP dump of a normal object 00258 * 00259 * id object ID 00260 * u4 stack trace serial number 00261 * id class object ID 00262 * u4 number of bytes that follow 00263 * [vl]* instance field values (class, followed 00264 * by super, super's super ...) 00265 * 00266 * HPROF_GC_OBJ_ARRAY_DUMP dump of an object array 00267 * 00268 * id array object ID 00269 * u4 stack trace serial number 00270 * u4 number of elements 00271 * id array class ID 00272 * [id]* elements 00273 * 00274 * HPROF_GC_PRIM_ARRAY_DUMP dump of a primitive array 00275 * 00276 * id array object ID 00277 * u4 stack trace serial number 00278 * u4 number of elements 00279 * u1 element type 00280 * 4: boolean array 00281 * 5: char array 00282 * 6: float array 00283 * 7: double array 00284 * 8: byte array 00285 * 9: short array 00286 * 10: int array 00287 * 11: long array 00288 * [u1]* elements 00289 * 00290 * HPROF_HEAP_DUMP_END terminates series of heap dump segments 00291 * 00292 * HPROF_CPU_SAMPLES a set of sample traces of running threads 00293 * 00294 * u4 total number of samples 00295 * u4 # of traces 00296 * [u4 # of samples 00297 * u4]* stack trace serial number 00298 * 00299 * HPROF_CONTROL_SETTINGS the settings of on/off switches 00300 * 00301 * u4 0x00000001: alloc traces on/off 00302 * 0x00000002: cpu sampling on/off 00303 * u2 stack trace depth 00304 * 00305 */ 00306 00307 typedef enum HprofTag { 00308 HPROF_UTF8 = 0x01, 00309 HPROF_LOAD_CLASS = 0x02, 00310 HPROF_UNLOAD_CLASS = 0x03, 00311 HPROF_FRAME = 0x04, 00312 HPROF_TRACE = 0x05, 00313 HPROF_ALLOC_SITES = 0x06, 00314 HPROF_HEAP_SUMMARY = 0x07, 00315 HPROF_START_THREAD = 0x0A, 00316 HPROF_END_THREAD = 0x0B, 00317 HPROF_HEAP_DUMP = 0x0C, 00318 HPROF_HEAP_DUMP_SEGMENT = 0x1C, /* 1.0.2 only */ 00319 HPROF_HEAP_DUMP_END = 0x2C, /* 1.0.2 only */ 00320 HPROF_CPU_SAMPLES = 0x0D, 00321 HPROF_CONTROL_SETTINGS = 0x0E 00322 } HprofTag; 00323 00324 /* 00325 * Heap dump constants 00326 */ 00327 00328 typedef enum HprofGcTag { 00329 HPROF_GC_ROOT_UNKNOWN = 0xFF, 00330 HPROF_GC_ROOT_JNI_GLOBAL = 0x01, 00331 HPROF_GC_ROOT_JNI_LOCAL = 0x02, 00332 HPROF_GC_ROOT_JAVA_FRAME = 0x03, 00333 HPROF_GC_ROOT_NATIVE_STACK = 0x04, 00334 HPROF_GC_ROOT_STICKY_CLASS = 0x05, 00335 HPROF_GC_ROOT_THREAD_BLOCK = 0x06, 00336 HPROF_GC_ROOT_MONITOR_USED = 0x07, 00337 HPROF_GC_ROOT_THREAD_OBJ = 0x08, 00338 HPROF_GC_CLASS_DUMP = 0x20, 00339 HPROF_GC_INSTANCE_DUMP = 0x21, 00340 HPROF_GC_OBJ_ARRAY_DUMP = 0x22, 00341 HPROF_GC_PRIM_ARRAY_DUMP = 0x23 00342 } HprofGcTag; 00343 00344 enum HprofType { 00345 HPROF_ARRAY_OBJECT = 1, 00346 HPROF_NORMAL_OBJECT = 2, 00347 HPROF_BOOLEAN = 4, 00348 HPROF_CHAR = 5, 00349 HPROF_FLOAT = 6, 00350 HPROF_DOUBLE = 7, 00351 HPROF_BYTE = 8, 00352 HPROF_SHORT = 9, 00353 HPROF_INT = 10, 00354 HPROF_LONG = 11 00355 }; 00356 typedef unsigned char HprofType; 00357 00358 #define HPROF_TYPE_SIZES \ 00359 { \ 00360 /*Object?*/ sizeof(HprofId), \ 00361 /*Object?*/ sizeof(HprofId), \ 00362 /*Array*/ sizeof(HprofId), \ 00363 /*Object?*/ sizeof(HprofId), \ 00364 /*jboolean*/ 1, \ 00365 /*jchar*/ 2, \ 00366 /*jfloat*/ 4, \ 00367 /*jdouble*/ 8, \ 00368 /*jbyte*/ 1, \ 00369 /*jshort*/ 2, \ 00370 /*jint*/ 4, \ 00371 /*jlong*/ 8 \ 00372 } 00373 00374 #define HPROF_TYPE_IS_PRIMITIVE(ty) ((ty)>=HPROF_BOOLEAN) 00375 00376 #endif 00377
1.6.1