1 /* 2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * - Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * - Neither the name of Oracle nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * This source code is provided to illustrate the usage of a given feature 34 * or technique and has been deliberately simplified. Additional steps 35 * required for a production-quality application, such as security checks, 36 * input validation and proper error handling, might not be present in 37 * this sample code. 38 */ 39 40 41 #ifndef HPROF_IO_H 42 #define HPROF_IO_H 43 44 void io_flush(void); 45 void io_setup(void); 46 void io_cleanup(void); 47 48 void io_write_file_header(void); 49 void io_write_file_footer(void); 50 51 void io_write_class_load(SerialNumber class_serial_num, ObjectIndex index, 52 SerialNumber trace_serial_num, char *csig); 53 void io_write_class_unload(SerialNumber class_serial_num, ObjectIndex index); 54 55 void io_write_sites_header(const char * comment_str, jint flags, 56 double cutoff, jint total_live_bytes, 57 jint total_live_instances, jlong total_alloced_bytes, 58 jlong total_alloced_instances, jint count); 59 void io_write_sites_elem(jint index, double ratio, double accum_percent, 60 char *csig, SerialNumber class_serial_num, 61 SerialNumber trace_serial_num, 62 jint n_live_bytes, jint n_live_instances, 63 jint n_alloced_bytes, jint n_alloced_instances); 64 void io_write_sites_footer(void); 65 66 void io_write_thread_start(SerialNumber thread_serial_num, TlsIndex tls_index, 67 SerialNumber trace_serial_num, char *thread_name, 68 char *thread_group_name, char *thread_parent_name); 69 void io_write_thread_end(SerialNumber thread_serial_num); 70 71 void io_write_frame(FrameIndex index, SerialNumber serial_num, 72 char *mname, char *msig, 73 char *sname, SerialNumber class_serial_num, 74 jint lineno); 75 76 void io_write_trace_header(SerialNumber trace_serial_num, 77 SerialNumber thread_serial_num, jint n_frames, 78 char * phase_str); 79 void io_write_trace_elem(SerialNumber trace_serial_num, 80 FrameIndex frame_index, SerialNumber frame_serial_num, 81 char *csig, char *mname, 82 char *sname, jint lineno); 83 void io_write_trace_footer(SerialNumber trace_serial_num, 84 SerialNumber thread_serial_num, jint n_frames); 85 86 void io_write_cpu_samples_header(jlong total_cost, jint n_items); 87 void io_write_cpu_samples_elem(jint index, double percent, double accum, 88 jint num_hits, jlong cost, 89 SerialNumber trace_serial_num, jint n_frames, 90 char *csig, char *mname); 91 void io_write_cpu_samples_footer(void); 92 93 void io_write_heap_summary(jlong total_live_bytes, jlong total_live_instances, 94 jlong total_alloced_bytes, 95 jlong total_alloced_instances); 96 97 void io_write_oldprof_header(void); 98 void io_write_oldprof_elem(jint num_hits, jint num_frames, char *csig_callee, 99 char *mname_callee, char *msig_callee, 100 char *csig_caller, char *mname_caller, 101 char *msig_caller, jlong cost); 102 void io_write_oldprof_footer(void); 103 104 void io_write_monitor_header(jlong total_time); 105 void io_write_monitor_elem(jint index, double percent, double accum, 106 jint num_hits, SerialNumber trace_serial_num, 107 char *sig); 108 void io_write_monitor_footer(void); 109 110 void io_write_monitor_sleep(jlong timeout, SerialNumber thread_serial_num); 111 void io_write_monitor_wait(char *sig, jlong timeout, 112 SerialNumber thread_serial_num); 113 void io_write_monitor_waited(char *sig, jlong time_waited, 114 SerialNumber thread_serial_num); 115 void io_write_monitor_exit(char *sig, SerialNumber thread_serial_num); 116 117 void io_write_monitor_dump_header(void); 118 void io_write_monitor_dump_thread_state(SerialNumber thread_serial_num, 119 SerialNumber trace_serial_num, 120 jint threadState); 121 void io_write_monitor_dump_state(char *sig, 122 SerialNumber thread_serial_num, jint entry_count, 123 SerialNumber *waiters, jint waiter_count, 124 SerialNumber *notify_waiters, jint notify_waiter_count); 125 void io_write_monitor_dump_footer(void); 126 127 void io_heap_header(jlong total_live_instances, jlong total_live_bytes); 128 129 void io_heap_root_thread_object(ObjectIndex thread_id, 130 SerialNumber thread_serial_num, 131 SerialNumber trace_serial_num); 132 void io_heap_root_unknown(ObjectIndex obj_id); 133 void io_heap_root_jni_global(ObjectIndex obj_id, SerialNumber gref_serial_num, 134 SerialNumber trace_serial_num); 135 void io_heap_root_jni_local(ObjectIndex obj_id, 136 SerialNumber thread_serial_num, jint frame_depth); 137 void io_heap_root_system_class(ObjectIndex obj_id, char *sig, SerialNumber class_serial_num); 138 void io_heap_root_monitor(ObjectIndex obj_id); 139 void io_heap_root_thread(ObjectIndex obj_id, 140 SerialNumber thread_serial_num); 141 void io_heap_root_java_frame(ObjectIndex obj_id, 142 SerialNumber thread_serial_num, jint frame_depth); 143 void io_heap_root_native_stack(ObjectIndex obj_id, 144 SerialNumber thread_serial_num); 145 146 void io_heap_class_dump(ClassIndex cnum, char *sig, ObjectIndex class_id, 147 SerialNumber trace_serial_num, 148 ObjectIndex super_id, ObjectIndex loader_id, 149 ObjectIndex signers_id, ObjectIndex domain_id, 150 jint inst_size, 151 jint n_cpool, ConstantPoolValue *cpool, 152 jint n_fields, FieldInfo *fields, jvalue *fvalues); 153 154 void io_heap_instance_dump(ClassIndex cnum, ObjectIndex obj_id, 155 SerialNumber trace_serial_num, 156 ObjectIndex class_id, jint size, 157 char *sig, FieldInfo *fields, 158 jvalue *fvalues, jint n_fields); 159 160 void io_heap_object_array(ObjectIndex obj_id, SerialNumber trace_serial_num, 161 jint size, jint num_elements, char *sig, 162 ObjectIndex *values, ObjectIndex class_id); 163 void io_heap_prim_array(ObjectIndex obj_id, SerialNumber trace_serial_num, 164 jint size, jint num_elements, char *sig, 165 void *elements); 166 167 void io_heap_footer(void); 168 169 #endif