xref: /haiku/headers/private/system/system_profiler_defs.h (revision 1b80286772b529a3d6de3bbeb0720c62e6a32fed)
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 	char		args[1];
85 };
86 
87 // B_SYSTEM_PROFILER_TEAM_REMOVED
88 struct system_profiler_team_removed {
89 	team_id		team;
90 };
91 
92 // B_SYSTEM_PROFILER_TEAM_EXEC
93 struct system_profiler_team_exec {
94 	team_id		team;
95 	char		thread_name[B_OS_NAME_LENGTH];
96 	char		args[1];
97 };
98 
99 // B_SYSTEM_PROFILER_THREAD_ADDED
100 struct system_profiler_thread_added {
101 	team_id		team;
102 	thread_id	thread;
103 	char		name[B_OS_NAME_LENGTH];
104 };
105 
106 // B_SYSTEM_PROFILER_THREAD_REMOVED
107 struct system_profiler_thread_removed {
108 	team_id		team;
109 	thread_id	thread;
110 };
111 
112 // B_SYSTEM_PROFILER_IMAGE_ADDED
113 struct system_profiler_image_added {
114 	team_id		team;
115 	image_info	info;
116 };
117 
118 // B_SYSTEM_PROFILER_IMAGE_REMOVED
119 struct system_profiler_image_removed {
120 	team_id		team;
121 	image_id	image;
122 };
123 
124 // B_SYSTEM_PROFILER_SAMPLES
125 struct system_profiler_samples {
126 	thread_id	thread;
127 	addr_t		samples[0];
128 };
129 
130 // B_SYSTEM_PROFILER_THREAD_SCHEDULED,
131 struct system_profiler_thread_scheduled {
132 	bigtime_t	time;
133 	thread_id	thread;
134 	thread_id	previous_thread;
135 	uint16		previous_thread_state;
136 	uint16		previous_thread_wait_object_type;
137 	addr_t		previous_thread_wait_object;
138 };
139 
140 // B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE,
141 struct system_profiler_thread_enqueued_in_run_queue {
142 	bigtime_t	time;
143 	thread_id	thread;
144 	uint8		priority;
145 };
146 
147 // B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE,
148 struct system_profiler_thread_removed_from_run_queue {
149 	bigtime_t	time;
150 	thread_id	thread;
151 };
152 
153 // B_SYSTEM_PROFILER_WAIT_OBJECT_INFO
154 struct system_profiler_wait_object_info {
155 	uint32		type;
156 	addr_t		object;
157 	addr_t		referenced_object;
158 	char		name[1];
159 };
160 
161 
162 #endif	/* _SYSTEM_SYSTEM_PROFILER_DEFS_H */
163