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