xref: /haiku/headers/os/kernel/debugger.h (revision 5629675a326ecf2ff3fd23f154beb525c171048d)
1 /*
2  * Copyright 2005-2016 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _DEBUGGER_H
6 #define _DEBUGGER_H
7 
8 
9 #include <signal.h>
10 
11 #include <image.h>
12 #include <OS.h>
13 
14 // include architecture specific definitions
15 #include <arch/x86/arch_debugger.h>
16 #include <arch/x86_64/arch_debugger.h>
17 #include <arch/ppc/arch_debugger.h>
18 #include <arch/m68k/arch_debugger.h>
19 #include <arch/mipsel/arch_debugger.h>
20 #include <arch/arm/arch_debugger.h>
21 #include <arch/sparc/arch_debugger.h>
22 
23 
24 #if defined(__x86_64__)
25 	typedef struct x86_64_debug_cpu_state debug_cpu_state;
26 #elif defined(__INTEL__)
27 	typedef struct x86_debug_cpu_state debug_cpu_state;
28 #elif defined(__POWERPC__)
29 	typedef struct ppc_debug_cpu_state debug_cpu_state;
30 #elif defined(__M68K__)
31 	typedef struct m68k_debug_cpu_state debug_cpu_state;
32 #elif defined(__MIPSEL__)
33 	typedef struct mipsel_debug_cpu_state debug_cpu_state;
34 #elif defined(__arm__)
35 	typedef struct arm_debug_cpu_state debug_cpu_state;
36 #elif defined(__sparc64__)
37 	typedef struct sparc_debug_cpu_state debug_cpu_state;
38 #else
39 	#error unsupported architecture
40 #endif
41 
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 extern status_t	install_default_debugger(port_id debuggerPort);
48 extern port_id	install_team_debugger(team_id team, port_id debuggerPort);
49 extern status_t	remove_team_debugger(team_id team);
50 extern status_t	debug_thread(thread_id thread);
51 extern void		wait_for_debugger(void);
52 
53 // EXPERIMENTAL: Self-debugging functions. Will fail when a team debugger is
54 // installed. A breakpoint/watchpoint hit will cause the default debugger to
55 // be installed for the team.
56 extern status_t	set_debugger_breakpoint(void *address);
57 extern status_t	clear_debugger_breakpoint(void *address);
58 extern status_t	set_debugger_watchpoint(void *address, uint32 type,
59 					int32 length);
60 extern status_t	clear_debugger_watchpoint(void *address);
61 
62 
63 // team debugging flags
64 enum {
65 	// event mask: If a flag is set, any of the team's threads will stop when
66 	// the respective event occurs. None of the flags are enabled by default.
67 	// Always enabled are debugger() calls and hardware exceptions, as well as
68 	// the deletion of the debugged team.
69 	B_TEAM_DEBUG_SIGNALS						= 0x00010000,
70 	B_TEAM_DEBUG_PRE_SYSCALL					= 0x00020000,
71 	B_TEAM_DEBUG_POST_SYSCALL					= 0x00040000,
72 	B_TEAM_DEBUG_TEAM_CREATION					= 0x00080000,
73 	B_TEAM_DEBUG_THREADS						= 0x00100000,
74 	B_TEAM_DEBUG_IMAGES							= 0x00200000,
75 	B_TEAM_DEBUG_PREVENT_EXIT					= 0x00400000,
76 
77 	// new thread handling
78 	B_TEAM_DEBUG_STOP_NEW_THREADS				= 0x01000000,
79 
80 	B_TEAM_DEBUG_USER_FLAG_MASK					= 0xffff0000,
81 };
82 
83 // per-thread debugging flags
84 enum {
85 	// event mask: If a flag is set, the thread will stop when the respective
86 	// event occurs. If there is a corresponding team flag, it is sufficient,
87 	// if either is set. Per default none of the flags is set.
88 	B_THREAD_DEBUG_PRE_SYSCALL					= 0x00010000,
89 	B_THREAD_DEBUG_POST_SYSCALL					= 0x00020000,
90 
91 	// child thread handling
92 	B_THREAD_DEBUG_STOP_CHILD_THREADS			= 0x00100000,
93 	B_THREAD_DEBUG_SYSCALL_TRACE_CHILD_THREADS	= 0x00200000,
94 
95 	B_THREAD_DEBUG_USER_FLAG_MASK				= 0xffff0000,
96 };
97 
98 // in case of a B_EXCEPTION_OCCURRED event: the type of the exception
99 typedef enum {
100 	B_NON_MASKABLE_INTERRUPT	= 0,
101 	B_MACHINE_CHECK_EXCEPTION,
102 	B_SEGMENT_VIOLATION,
103 	B_ALIGNMENT_EXCEPTION,
104 	B_DIVIDE_ERROR,
105 	B_OVERFLOW_EXCEPTION,
106 	B_BOUNDS_CHECK_EXCEPTION,
107 	B_INVALID_OPCODE_EXCEPTION,
108 	B_SEGMENT_NOT_PRESENT,
109 	B_STACK_FAULT,
110 	B_GENERAL_PROTECTION_FAULT,
111 	B_FLOATING_POINT_EXCEPTION,
112 } debug_exception_type;
113 
114 // Value indicating how a stopped thread shall continue.
115 enum {
116 	B_THREAD_DEBUG_HANDLE_EVENT = 0,	// handle the event normally
117 										// (e.g. a signal is delivered, a
118 										// CPU fault kills the team,...)
119 	B_THREAD_DEBUG_IGNORE_EVENT,		// ignore the event and continue as if
120 										// it didn't occur (e.g. a signal or
121 										// a CPU fault will be ignored)
122 };
123 
124 // watchpoint types (ToDo: Check PPC support.)
125 enum {
126 	B_DATA_READ_WATCHPOINT = 0,			// !x86
127 	B_DATA_WRITE_WATCHPOINT,
128 	B_DATA_READ_WRITE_WATCHPOINT,
129 };
130 
131 // how to apply signal ignore masks
132 typedef enum {
133 	B_DEBUG_SIGNAL_MASK_AND	= 0,
134 	B_DEBUG_SIGNAL_MASK_OR,
135 	B_DEBUG_SIGNAL_MASK_SET,
136 } debug_signal_mask_op;
137 
138 #define B_DEBUG_SIGNAL_TO_MASK(signal) (1ULL << ((signal) - 1))
139 
140 // maximal number of bytes to read/write via B_DEBUG_MESSAGE_{READ,WRITE]_MEMORY
141 enum {
142 	B_MAX_READ_WRITE_MEMORY_SIZE	= 1024,
143 };
144 
145 // messages to the debug nub thread
146 typedef enum {
147 	B_DEBUG_MESSAGE_READ_MEMORY	= 0,	// read from the team's memory
148 	B_DEBUG_MESSAGE_WRITE_MEMORY,		// write to the team's memory
149 	B_DEBUG_MESSAGE_SET_TEAM_FLAGS,		// set the team's debugging flags
150 	B_DEBUG_MESSAGE_SET_THREAD_FLAGS,	// set a thread's debugging flags
151 	B_DEBUG_MESSAGE_CONTINUE_THREAD,	// continue a stopped thread
152 	B_DEBUG_MESSAGE_SET_CPU_STATE,		// change a stopped thread's CPU state
153 	B_DEBUG_MESSAGE_GET_CPU_STATE,		// get the thread's current CPU state
154 	B_DEBUG_MESSAGE_SET_BREAKPOINT,		// set a breakpoint
155 	B_DEBUG_MESSAGE_CLEAR_BREAKPOINT,	// clear a breakpoint
156 	B_DEBUG_MESSAGE_SET_WATCHPOINT,		// set a watchpoint
157 	B_DEBUG_MESSAGE_CLEAR_WATCHPOINT,	// clear a watchpoint
158 	B_DEBUG_MESSAGE_SET_SIGNAL_MASKS,	// set/get a thread's masks of signals
159 	B_DEBUG_MESSAGE_GET_SIGNAL_MASKS,	//  the debugger is interested in
160 	B_DEBUG_MESSAGE_SET_SIGNAL_HANDLER,	// set/get the team's signal handler for
161 	B_DEBUG_MESSAGE_GET_SIGNAL_HANDLER,	//  a signal
162 
163 	B_DEBUG_MESSAGE_PREPARE_HANDOVER,	// prepares the debugged team for being
164 										// handed over to another debugger;
165 										// the new debugger can just invoke
166 										// install_team_debugger()
167 
168 	B_DEBUG_START_PROFILER,				// start/stop sampling
169 	B_DEBUG_STOP_PROFILER,				//
170 
171 	B_DEBUG_WRITE_CORE_FILE				// write a core file
172 } debug_nub_message;
173 
174 // messages sent to the debugger
175 typedef enum {
176 	B_DEBUGGER_MESSAGE_THREAD_DEBUGGED = 0,	// debugger message in reaction to
177 											// an invocation of debug_thread()
178 	B_DEBUGGER_MESSAGE_DEBUGGER_CALL,		// thread called debugger()
179 	B_DEBUGGER_MESSAGE_BREAKPOINT_HIT,		// thread hit a breakpoint
180 	B_DEBUGGER_MESSAGE_WATCHPOINT_HIT,		// thread hit a watchpoint
181 	B_DEBUGGER_MESSAGE_SINGLE_STEP,			// thread was single-stepped
182 	B_DEBUGGER_MESSAGE_PRE_SYSCALL,			// begin of a syscall
183 	B_DEBUGGER_MESSAGE_POST_SYSCALL,		// end of a syscall
184 	B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED,		// thread received a signal
185 	B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED,	// an exception occurred
186 	B_DEBUGGER_MESSAGE_TEAM_CREATED,		// the debugged team created a new
187 											// one
188 	B_DEBUGGER_MESSAGE_TEAM_DELETED,		// the debugged team is gone
189 	B_DEBUGGER_MESSAGE_TEAM_EXEC,			// the debugged team executes exec()
190 	B_DEBUGGER_MESSAGE_THREAD_CREATED,		// a thread has been created
191 	B_DEBUGGER_MESSAGE_THREAD_DELETED,		// a thread has been deleted
192 	B_DEBUGGER_MESSAGE_IMAGE_CREATED,		// an image has been created
193 	B_DEBUGGER_MESSAGE_IMAGE_DELETED,		// an image has been deleted
194 
195 	B_DEBUGGER_MESSAGE_PROFILER_UPDATE,		// flush the profiling buffer for a
196 											// thread
197 
198 	B_DEBUGGER_MESSAGE_HANDED_OVER,			// the debugged team has been
199 											// handed over to another debugger,
200 											// sent to both debuggers
201 } debug_debugger_message;
202 
203 
204 // profile events -- when the buffer is in variable stack depth format, a sample
205 // count entry >= B_DEBUG_PROFILE_EVENT_BASE indicates a profile event
206 enum {
207 	B_DEBUG_PROFILE_EVENT_BASE				= 0x80000000,
208 	B_DEBUG_PROFILE_EVENT_PARAMETER_MASK	= 0x0000ffff,
209 		// & with to get the event's parameter count
210 
211 	B_DEBUG_PROFILE_IMAGE_EVENT				= 0x80010001
212 		// single parameter: the respective image event counter
213 };
214 
215 
216 // #pragma mark -
217 // #pragma mark ----- messages to the debug nub thread -----
218 
219 // B_DEBUG_MESSAGE_READ_MEMORY
220 
221 typedef struct {
222 	port_id		reply_port;		// port to send the reply to
223 	void		*address;		// address from which to read
224 	int32		size;			// number of bytes to read
225 } debug_nub_read_memory;
226 
227 typedef struct {
228 	status_t	error;			// B_OK, if reading went fine
229 	int32		size;			// the number of bytes actually read
230 								// > 0, iff error == B_OK
231 	char		data[B_MAX_READ_WRITE_MEMORY_SIZE];
232 								// the read data
233 } debug_nub_read_memory_reply;
234 
235 // B_DEBUG_MESSAGE_WRITE_MEMORY
236 
237 typedef struct {
238 	port_id		reply_port;		// port to send the reply to
239 	void		*address;		// address to which to write
240 	int32		size;			// number of bytes to write
241 	char		data[B_MAX_READ_WRITE_MEMORY_SIZE];
242 								// data to write
243 } debug_nub_write_memory;
244 
245 typedef struct {
246 	status_t	error;			// B_OK, if writing went fine
247 	int32		size;			// the number of bytes actually written
248 } debug_nub_write_memory_reply;
249 
250 // B_DEBUG_MESSAGE_SET_TEAM_FLAGS
251 
252 typedef struct {
253 	int32		flags;			// the new team debugging flags
254 } debug_nub_set_team_flags;
255 
256 // B_DEBUG_MESSAGE_SET_THREAD_FLAGS
257 
258 typedef struct {
259 	thread_id	thread;			// the thread
260 	int32		flags;			// the new thread debugging flags
261 } debug_nub_set_thread_flags;
262 
263 // B_DEBUG_MESSAGE_CONTINUE_THREAD
264 
265 typedef struct {
266 	thread_id	thread;			// the thread
267 	uint32		handle_event;	// how to handle the occurred event
268 	bool		single_step;	// true == single step, false == run full speed
269 } debug_nub_continue_thread;
270 
271 // B_DEBUG_MESSAGE_SET_CPU_STATE
272 
273 typedef struct {
274 	thread_id			thread;				// the thread
275 	debug_cpu_state		cpu_state;			// the new CPU state
276 } debug_nub_set_cpu_state;
277 
278 // B_DEBUG_MESSAGE_GET_CPU_STATE
279 
280 typedef struct {
281 	port_id					reply_port;		// port to send the reply to
282 	thread_id				thread;			// the thread
283 } debug_nub_get_cpu_state;
284 
285 typedef struct {
286 	status_t				error;		// != B_OK, if something went wrong
287 										// (bad thread ID, thread not stopped)
288 	debug_debugger_message	message;	// the reason why the thread stopped
289 	debug_cpu_state			cpu_state;	// the thread's CPU state
290 } debug_nub_get_cpu_state_reply;
291 
292 // B_DEBUG_MESSAGE_SET_BREAKPOINT
293 
294 typedef struct {
295 	port_id		reply_port;		// port to send the reply to
296 	void		*address;		// breakpoint address
297 } debug_nub_set_breakpoint;
298 
299 typedef struct {
300 	status_t	error;			// B_OK, if the breakpoint has been set
301 								// successfully
302 } debug_nub_set_breakpoint_reply;
303 
304 // B_DEBUG_MESSAGE_CLEAR_BREAKPOINT
305 
306 typedef struct {
307 	void		*address;		// breakpoint address
308 } debug_nub_clear_breakpoint;
309 
310 // B_DEBUG_MESSAGE_SET_WATCHPOINT
311 
312 typedef struct {
313 	port_id		reply_port;		// port to send the reply to
314 	void		*address;		// watchpoint address
315 	uint32		type;			// watchpoint type (see type constants above)
316 	int32		length;			// number of bytes to watch (typically 1, 2,
317 								// 4); architecture specific alignment
318 								// restrictions apply.
319 } debug_nub_set_watchpoint;
320 
321 typedef struct {
322 	status_t	error;			// B_OK, if the watchpoint has been set
323 								// successfully
324 } debug_nub_set_watchpoint_reply;
325 
326 // B_DEBUG_MESSAGE_CLEAR_WATCHPOINT
327 
328 typedef struct {
329 	void		*address;		// watchpoint address
330 } debug_nub_clear_watchpoint;
331 
332 // B_DEBUG_MESSAGE_SET_SIGNAL_MASKS
333 
334 typedef struct {
335 	thread_id				thread;				// the thread
336 	uint64					ignore_mask;		// the mask for signals the
337 												// debugger wishes not to be
338 												// notified of
339 	uint64					ignore_once_mask;	// the mask for signals the
340 												// debugger wishes not to be
341 												// notified of when they next
342 												// occur
343 	debug_signal_mask_op	ignore_op;			// what to do with ignore_mask
344 	debug_signal_mask_op	ignore_once_op;		// what to do with
345 												// ignore_once_mask
346 } debug_nub_set_signal_masks;
347 
348 // B_DEBUG_MESSAGE_GET_SIGNAL_MASKS
349 
350 typedef struct {
351 	port_id		reply_port;			// port to send the reply to
352 	thread_id	thread;				// the thread
353 } debug_nub_get_signal_masks;
354 
355 typedef struct {
356 	status_t	error;				// B_OK, if the thread exists
357 	uint64		ignore_mask;		// the mask for signals the debugger wishes
358 									// not to be notified of
359 	uint64		ignore_once_mask;	// the mask for signals the debugger wishes
360 									// not to be notified of when they next
361 									// occur
362 } debug_nub_get_signal_masks_reply;
363 
364 // B_DEBUG_MESSAGE_SET_SIGNAL_HANDLER
365 
366 typedef struct {
367 	int					signal;		// the signal
368 	struct sigaction	handler;	// the new signal handler
369 } debug_nub_set_signal_handler;
370 
371 // B_DEBUG_MESSAGE_GET_SIGNAL_HANDLER
372 
373 typedef struct {
374 	port_id				reply_port;	// port to send the reply to
375 	int					signal;		// the signal
376 } debug_nub_get_signal_handler;
377 
378 typedef struct {
379 	status_t			error;		// B_OK, if the thread exists
380 	struct sigaction	handler;	// the signal handler
381 } debug_nub_get_signal_handler_reply;
382 
383 // B_DEBUG_MESSAGE_PREPARE_HANDOVER
384 
385 // no parameters, no reply
386 
387 // B_DEBUG_START_PROFILER
388 
389 struct debug_profile_function {
390 	addr_t			base;	// function base address
391 	size_t			size;	// function size
392 };
393 
394 typedef struct {
395 	port_id				reply_port;		// port to send the reply to
396 	thread_id			thread;			// thread to profile
397 	bigtime_t			interval;		// sample interval
398 	area_id				sample_area;	// area into which the sample will be
399 										// written
400 	int32				stack_depth;	// number of return address per hit
401 	bool				variable_stack_depth;
402 										// variable number of samples per hit;
403 										// cf. debug_profiler_update
404 } debug_nub_start_profiler;
405 
406 typedef struct {
407 	status_t			error;
408 	int32				image_event;	// number of the last image event
409 	bigtime_t			interval;		// actual sample interval (might
410 										// differ from the requested one)
411 } debug_nub_start_profiler_reply;
412 
413 // B_DEBUG_STOP_PROFILER
414 
415 typedef struct {
416 	port_id				reply_port;		// port to send the reply to
417 	thread_id			thread;			// thread to profile
418 } debug_nub_stop_profiler;
419 
420 // B_DEBUG_WRITE_CORE_FILE
421 
422 typedef struct {
423 	port_id				reply_port;		// port to send the reply to
424 	char				path[B_PATH_NAME_LENGTH];
425 										// path of the core file; must not exist
426 										// yet; must be absolute
427 } debug_nub_write_core_file;
428 
429 typedef struct {
430 	status_t	error;					// B_OK on success
431 } debug_nub_write_core_file_reply;
432 
433 
434 // reply is debug_profiler_update
435 
436 // union of all messages structures sent to the debug nub thread
437 typedef union {
438 	debug_nub_read_memory			read_memory;
439 	debug_nub_write_memory			write_memory;
440 	debug_nub_set_team_flags		set_team_flags;
441 	debug_nub_set_thread_flags		set_thread_flags;
442 	debug_nub_continue_thread		continue_thread;
443 	debug_nub_set_cpu_state			set_cpu_state;
444 	debug_nub_get_cpu_state			get_cpu_state;
445 	debug_nub_set_breakpoint		set_breakpoint;
446 	debug_nub_clear_breakpoint		clear_breakpoint;
447 	debug_nub_set_watchpoint		set_watchpoint;
448 	debug_nub_clear_watchpoint		clear_watchpoint;
449 	debug_nub_set_signal_masks		set_signal_masks;
450 	debug_nub_get_signal_masks		get_signal_masks;
451 	debug_nub_set_signal_handler	set_signal_handler;
452 	debug_nub_get_signal_handler	get_signal_handler;
453 	debug_nub_start_profiler		start_profiler;
454 	debug_nub_stop_profiler			stop_profiler;
455 	debug_nub_write_core_file		write_core_file;
456 } debug_nub_message_data;
457 
458 
459 // #pragma mark -
460 // #pragma mark ----- messages to the debugger -----
461 
462 // first member of all debugger messages -- not a message by itself
463 typedef struct {
464 	thread_id	thread;			// the thread being the event origin
465 	team_id		team;			// the thread's team
466 	port_id		nub_port;		// port to debug nub for this team (only set
467 								// for synchronous messages)
468 } debug_origin;
469 
470 // B_DEBUGGER_MESSAGE_THREAD_DEBUGGED
471 
472 typedef struct {
473 	debug_origin		origin;
474 } debug_thread_debugged;
475 
476 // B_DEBUGGER_MESSAGE_DEBUGGER_CALL
477 
478 typedef struct {
479 	debug_origin		origin;
480 	void				*message;	// address of the message passed to
481 									// debugger()
482 } debug_debugger_call;
483 
484 // B_DEBUGGER_MESSAGE_BREAKPOINT_HIT
485 
486 typedef struct {
487 	debug_origin		origin;
488 	debug_cpu_state		cpu_state;	// cpu state
489 } debug_breakpoint_hit;
490 
491 // B_DEBUGGER_MESSAGE_WATCHPOINT_HIT
492 
493 typedef struct {
494 	debug_origin		origin;
495 	debug_cpu_state		cpu_state;	// cpu state
496 } debug_watchpoint_hit;
497 
498 // B_DEBUGGER_MESSAGE_SINGLE_STEP
499 
500 typedef struct {
501 	debug_origin		origin;
502 	debug_cpu_state		cpu_state;	// cpu state
503 } debug_single_step;
504 
505 // B_DEBUGGER_MESSAGE_PRE_SYSCALL
506 
507 typedef struct {
508 	debug_origin	origin;
509 	uint32			syscall;		// the syscall number
510 	uint8			args[128];		// syscall arguments
511 } debug_pre_syscall;
512 
513 // B_DEBUGGER_MESSAGE_POST_SYSCALL
514 
515 typedef struct {
516 	debug_origin	origin;
517 	bigtime_t		start_time;		// time of syscall start
518 	bigtime_t		end_time;		// time of syscall completion
519 	uint64			return_value;	// the syscall's return value
520 	uint32			syscall;		// the syscall number
521 	uint8			args[128];		// syscall arguments
522 } debug_post_syscall;
523 
524 // B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED
525 
526 typedef struct {
527 	debug_origin		origin;
528 	int					signal;		// the signal
529 	struct sigaction	handler;	// the signal handler
530 	bool				deadly;		// true, if handling the signal will kill
531 									// the team
532 } debug_signal_received;
533 
534 // B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED
535 
536 typedef struct {
537 	debug_origin			origin;
538 	debug_exception_type	exception;		// the exception
539 	int						signal;			// the signal that will be sent,
540 											// when the thread continues
541 											// normally
542 } debug_exception_occurred;
543 
544 // B_DEBUGGER_MESSAGE_TEAM_CREATED
545 
546 typedef struct {
547 	debug_origin	origin;
548 	team_id			new_team;		// the newly created team
549 } debug_team_created;
550 
551 // B_DEBUGGER_MESSAGE_TEAM_DELETED
552 
553 typedef struct {
554 	debug_origin	origin;			// thread is < 0, team is the deleted team
555 									// (asynchronous message)
556 } debug_team_deleted;
557 
558 // B_DEBUGGER_MESSAGE_TEAM_EXEC
559 
560 typedef struct {
561 	debug_origin	origin;
562 	int32			image_event;	// number of the image event
563 } debug_team_exec;
564 
565 // B_DEBUGGER_MESSAGE_THREAD_CREATED
566 
567 typedef struct {
568 	debug_origin	origin;			// the thread that created the new thread
569 	team_id			new_thread;		// the newly created thread
570 } debug_thread_created;
571 
572 // B_DEBUGGER_MESSAGE_THREAD_DELETED
573 
574 typedef struct {
575 	debug_origin	origin;			// the deleted thread (asynchronous message)
576 } debug_thread_deleted;
577 
578 // B_DEBUGGER_MESSAGE_IMAGE_CREATED
579 
580 typedef struct {
581 	debug_origin	origin;
582 	image_info		info;			// info for the image
583 	int32			image_event;	// number of the image event
584 } debug_image_created;
585 
586 // B_DEBUGGER_MESSAGE_IMAGE_DELETED
587 
588 typedef struct {
589 	debug_origin	origin;
590 	image_info		info;			// info for the image
591 	int32			image_event;	// number of the image event
592 } debug_image_deleted;
593 
594 // B_DEBUGGER_MESSAGE_PROFILER_UPDATE
595 
596 typedef struct {
597 	debug_origin		origin;
598 	int32				image_event;	// number of the last image event; all
599 										// samples were recorded after this
600 										// event and before the next one
601 	int32				stack_depth;	// number of return addresses per tick
602 	int32				sample_count;	// number of samples in the buffer
603 	int32				dropped_ticks;	// number of ticks that had been
604 										// dropped, since the buffer was full
605 	bool				variable_stack_depth;
606 										// the number of samples per hit is
607 										// variable, i.e. the format for the
608 										// samples of a hit in the buffer is
609 										//   <n> <sample 1> ... <sample n>
610 										// instead of
611 										//   <sample 1> ... <sample stack_depth>
612 	bool				stopped;		// if true, the thread is no longer
613 										// being profiled
614 } debug_profiler_update;
615 
616 // B_DEBUGGER_MESSAGE_HANDED_OVER
617 
618 typedef struct {
619 	debug_origin	origin;			// thread is < 0, team is the deleted team
620 									// (asynchronous message)
621 	team_id			debugger;		// the new debugger
622 	port_id			debugger_port;	// the port the new debugger uses
623 	thread_id		causing_thread;	// the thread that caused entering the
624 									// debugger in the first place, -1 if the
625 									// debugger wasn't attached automatically
626 } debug_handed_over;
627 
628 // union of all messages structures sent to the debugger
629 typedef union {
630 	debug_thread_debugged			thread_debugged;
631 	debug_debugger_call				debugger_call;
632 	debug_breakpoint_hit			breakpoint_hit;
633 	debug_watchpoint_hit			watchpoint_hit;
634 	debug_single_step				single_step;
635 	debug_pre_syscall				pre_syscall;
636 	debug_post_syscall				post_syscall;
637 	debug_signal_received			signal_received;
638 	debug_exception_occurred		exception_occurred;
639 	debug_team_created				team_created;
640 	debug_team_deleted				team_deleted;
641 	debug_team_exec					team_exec;
642 	debug_thread_created			thread_created;
643 	debug_thread_deleted			thread_deleted;
644 	debug_image_created				image_created;
645 	debug_image_deleted				image_deleted;
646 	debug_profiler_update			profiler_update;
647 	debug_handed_over				handed_over;
648 
649 	debug_origin					origin;	// for convenience (no real message)
650 } debug_debugger_message_data;
651 
652 
653 extern void get_debug_message_string(debug_debugger_message message,
654 		char *buffer, int32 bufferSize);
655 extern void get_debug_exception_string(debug_exception_type exception,
656 		char *buffer, int32 bufferSize);
657 
658 
659 #ifdef __cplusplus
660 }	// extern "C"
661 #endif
662 
663 #endif	// _DEBUGGER_H
664