1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SYSTEM_SYSTEM_PROFILER_DEFS_H 6 #define _SYSTEM_SYSTEM_PROFILER_DEFS_H 7 8 9 #include <image.h> 10 11 12 struct system_profiler_parameters { 13 // general 14 area_id buffer_area; // area the events will be written to 15 uint32 flags; // flags selecting the events to receive 16 17 // scheduling 18 size_t locking_lookup_size; // size of the lookup table used for 19 // caching the locking primitive infos 20 21 // sampling 22 bigtime_t interval; // interval at which to take samples 23 uint32 stack_depth; // maximum stack depth to sample 24 }; 25 26 27 // event flags 28 enum { 29 B_SYSTEM_PROFILER_TEAM_EVENTS = 0x01, 30 B_SYSTEM_PROFILER_THREAD_EVENTS = 0x02, 31 B_SYSTEM_PROFILER_IMAGE_EVENTS = 0x04, 32 B_SYSTEM_PROFILER_SAMPLING_EVENTS = 0x08, 33 B_SYSTEM_PROFILER_SCHEDULING_EVENTS = 0x10, 34 B_SYSTEM_PROFILER_IO_SCHEDULING_EVENTS = 0x20 35 }; 36 37 38 // events 39 enum { 40 // reserved for the user application 41 B_SYSTEM_PROFILER_USER_EVENT = 0, 42 43 // ring buffer wrap-around marker 44 B_SYSTEM_PROFILER_BUFFER_END, 45 46 // team 47 B_SYSTEM_PROFILER_TEAM_ADDED, 48 B_SYSTEM_PROFILER_TEAM_REMOVED, 49 B_SYSTEM_PROFILER_TEAM_EXEC, 50 51 // thread 52 B_SYSTEM_PROFILER_THREAD_ADDED, 53 B_SYSTEM_PROFILER_THREAD_REMOVED, 54 55 // image 56 B_SYSTEM_PROFILER_IMAGE_ADDED, 57 B_SYSTEM_PROFILER_IMAGE_REMOVED, 58 59 // profiling samples 60 B_SYSTEM_PROFILER_SAMPLES, 61 62 // scheduling 63 B_SYSTEM_PROFILER_THREAD_SCHEDULED, 64 B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE, 65 B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE, 66 B_SYSTEM_PROFILER_WAIT_OBJECT_INFO, 67 68 // I/O scheduling 69 B_SYSTEM_PROFILER_IO_SCHEDULER_ADDED, 70 B_SYSTEM_PROFILER_IO_SCHEDULER_REMOVED, 71 B_SYSTEM_PROFILER_IO_REQUEST_SCHEDULED, 72 B_SYSTEM_PROFILER_IO_REQUEST_FINISHED, 73 B_SYSTEM_PROFILER_IO_OPERATION_STARTED, 74 B_SYSTEM_PROFILER_IO_OPERATION_FINISHED 75 }; 76 77 78 struct system_profiler_buffer_header { 79 size_t start; 80 size_t size; 81 }; 82 83 84 struct system_profiler_event_header { 85 uint8 event; 86 uint8 cpu; // only for B_SYSTEM_PROFILER_SAMPLES 87 uint16 size; // size of the event structure excluding the header 88 }; 89 90 91 // B_SYSTEM_PROFILER_TEAM_ADDED 92 struct system_profiler_team_added { 93 team_id team; 94 uint16 args_offset; 95 char name[1]; 96 }; 97 98 // B_SYSTEM_PROFILER_TEAM_REMOVED 99 struct system_profiler_team_removed { 100 team_id team; 101 }; 102 103 // B_SYSTEM_PROFILER_TEAM_EXEC 104 struct system_profiler_team_exec { 105 team_id team; 106 char thread_name[B_OS_NAME_LENGTH]; 107 char args[1]; 108 }; 109 110 // B_SYSTEM_PROFILER_THREAD_ADDED 111 struct system_profiler_thread_added { 112 team_id team; 113 thread_id thread; 114 char name[B_OS_NAME_LENGTH]; 115 }; 116 117 // B_SYSTEM_PROFILER_THREAD_REMOVED 118 struct system_profiler_thread_removed { 119 team_id team; 120 thread_id thread; 121 }; 122 123 // B_SYSTEM_PROFILER_IMAGE_ADDED 124 struct system_profiler_image_added { 125 team_id team; 126 image_info info; 127 }; 128 129 // B_SYSTEM_PROFILER_IMAGE_REMOVED 130 struct system_profiler_image_removed { 131 team_id team; 132 image_id image; 133 }; 134 135 // B_SYSTEM_PROFILER_SAMPLES 136 struct system_profiler_samples { 137 thread_id thread; 138 addr_t samples[0]; 139 }; 140 141 // base structure for the following three 142 struct system_profiler_thread_scheduling_event { 143 nanotime_t time; 144 thread_id thread; 145 }; 146 147 // B_SYSTEM_PROFILER_THREAD_SCHEDULED 148 struct system_profiler_thread_scheduled { 149 nanotime_t time; 150 thread_id thread; 151 thread_id previous_thread; 152 uint16 previous_thread_state; 153 uint16 previous_thread_wait_object_type; 154 addr_t previous_thread_wait_object; 155 }; 156 157 // B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE 158 struct system_profiler_thread_enqueued_in_run_queue { 159 nanotime_t time; 160 thread_id thread; 161 uint8 priority; 162 }; 163 164 // B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE 165 struct system_profiler_thread_removed_from_run_queue { 166 nanotime_t time; 167 thread_id thread; 168 }; 169 170 // B_SYSTEM_PROFILER_WAIT_OBJECT_INFO 171 struct system_profiler_wait_object_info { 172 uint32 type; 173 addr_t object; 174 addr_t referenced_object; 175 char name[1]; 176 }; 177 178 // B_SYSTEM_PROFILER_IO_SCHEDULER_ADDED 179 struct system_profiler_io_scheduler_added { 180 int32 scheduler; 181 char name[1]; 182 }; 183 184 // B_SYSTEM_PROFILER_IO_SCHEDULER_REMOVED 185 struct system_profiler_io_scheduler_removed { 186 int32 scheduler; 187 }; 188 189 // B_SYSTEM_PROFILER_IO_REQUEST_SCHEDULED 190 struct system_profiler_io_request_scheduled { 191 nanotime_t time; 192 int32 scheduler; 193 team_id team; 194 thread_id thread; 195 void* request; 196 off_t offset; 197 size_t length; 198 bool write; 199 uint8 priority; 200 }; 201 202 // B_SYSTEM_PROFILER_IO_REQUEST_FINISHED 203 struct system_profiler_io_request_finished { 204 nanotime_t time; 205 int32 scheduler; 206 void* request; 207 status_t status; 208 size_t transferred; 209 }; 210 211 // B_SYSTEM_PROFILER_IO_OPERATION_STARTED 212 struct system_profiler_io_operation_started { 213 nanotime_t time; 214 int32 scheduler; 215 void* request; 216 void* operation; 217 off_t offset; 218 size_t length; 219 bool write; 220 }; 221 222 // B_SYSTEM_PROFILER_IO_OPERATION_FINISHED 223 struct system_profiler_io_operation_finished { 224 nanotime_t time; 225 int32 scheduler; 226 void* request; 227 void* operation; 228 status_t status; 229 size_t transferred; 230 }; 231 232 233 #endif /* _SYSTEM_SYSTEM_PROFILER_DEFS_H */ 234