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 #include <image.h> 9 10 11 struct system_profiler_parameters { 12 // general 13 area_id buffer_area; // area the events will be written to 14 uint32 flags; // flags selecting the events to receive 15 16 // scheduling 17 size_t locking_lookup_size; // size of the lookup table used for 18 // caching the locking primitive infos 19 20 // sampling 21 bigtime_t interval; // interval at which to take samples 22 uint32 stack_depth; // maximum stack depth to sample 23 }; 24 25 26 // event flags 27 enum { 28 B_SYSTEM_PROFILER_TEAM_EVENTS = 0x01, 29 B_SYSTEM_PROFILER_THREAD_EVENTS = 0x02, 30 B_SYSTEM_PROFILER_IMAGE_EVENTS = 0x04, 31 B_SYSTEM_PROFILER_SAMPLING_EVENTS = 0x08, 32 B_SYSTEM_PROFILER_SCHEDULING_EVENTS = 0x10 33 }; 34 35 36 // events 37 enum { 38 // reserved for the user application 39 B_SYSTEM_PROFILER_USER_EVENT = 0, 40 41 // ring buffer wrap-around marker 42 B_SYSTEM_PROFILER_BUFFER_END, 43 44 // team 45 B_SYSTEM_PROFILER_TEAM_ADDED, 46 B_SYSTEM_PROFILER_TEAM_REMOVED, 47 B_SYSTEM_PROFILER_TEAM_EXEC, 48 49 // thread 50 B_SYSTEM_PROFILER_THREAD_ADDED, 51 B_SYSTEM_PROFILER_THREAD_REMOVED, 52 53 // image 54 B_SYSTEM_PROFILER_IMAGE_ADDED, 55 B_SYSTEM_PROFILER_IMAGE_REMOVED, 56 57 // profiling samples 58 B_SYSTEM_PROFILER_SAMPLES, 59 60 // scheduling 61 B_SYSTEM_PROFILER_THREAD_SCHEDULED, 62 B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE, 63 B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE, 64 B_SYSTEM_PROFILER_WAIT_OBJECT_INFO 65 }; 66 67 68 struct system_profiler_buffer_header { 69 size_t start; 70 size_t size; 71 }; 72 73 74 struct system_profiler_event_header { 75 uint8 event; 76 uint8 cpu; // only for B_SYSTEM_PROFILER_SAMPLES 77 uint16 size; // size of the event structure excluding the header 78 }; 79 80 81 // B_SYSTEM_PROFILER_TEAM_ADDED 82 struct system_profiler_team_added { 83 team_id team; 84 uint16 args_offset; 85 char name[1]; 86 }; 87 88 // B_SYSTEM_PROFILER_TEAM_REMOVED 89 struct system_profiler_team_removed { 90 team_id team; 91 }; 92 93 // B_SYSTEM_PROFILER_TEAM_EXEC 94 struct system_profiler_team_exec { 95 team_id team; 96 char thread_name[B_OS_NAME_LENGTH]; 97 char args[1]; 98 }; 99 100 // B_SYSTEM_PROFILER_THREAD_ADDED 101 struct system_profiler_thread_added { 102 team_id team; 103 thread_id thread; 104 char name[B_OS_NAME_LENGTH]; 105 }; 106 107 // B_SYSTEM_PROFILER_THREAD_REMOVED 108 struct system_profiler_thread_removed { 109 team_id team; 110 thread_id thread; 111 }; 112 113 // B_SYSTEM_PROFILER_IMAGE_ADDED 114 struct system_profiler_image_added { 115 team_id team; 116 image_info info; 117 }; 118 119 // B_SYSTEM_PROFILER_IMAGE_REMOVED 120 struct system_profiler_image_removed { 121 team_id team; 122 image_id image; 123 }; 124 125 // B_SYSTEM_PROFILER_SAMPLES 126 struct system_profiler_samples { 127 thread_id thread; 128 addr_t samples[0]; 129 }; 130 131 // B_SYSTEM_PROFILER_THREAD_SCHEDULED 132 struct system_profiler_thread_scheduled { 133 bigtime_t time; 134 thread_id thread; 135 thread_id previous_thread; 136 uint16 previous_thread_state; 137 uint16 previous_thread_wait_object_type; 138 addr_t previous_thread_wait_object; 139 }; 140 141 // B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE 142 struct system_profiler_thread_enqueued_in_run_queue { 143 bigtime_t time; 144 thread_id thread; 145 uint8 priority; 146 }; 147 148 // B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE 149 struct system_profiler_thread_removed_from_run_queue { 150 bigtime_t time; 151 thread_id thread; 152 }; 153 154 // B_SYSTEM_PROFILER_WAIT_OBJECT_INFO 155 struct system_profiler_wait_object_info { 156 uint32 type; 157 addr_t object; 158 addr_t referenced_object; 159 char name[1]; 160 }; 161 162 163 #endif /* _SYSTEM_SYSTEM_PROFILER_DEFS_H */ 164