* Enter the debugger due to a trap. */
| 679 | * Enter the debugger due to a trap. |
| 680 | */ |
| 681 | int |
| 682 | kdb_trap(int type, int code, struct trapframe *tf) |
| 683 | { |
| 684 | #ifdef SMP |
| 685 | cpuset_t other_cpus; |
| 686 | #endif |
| 687 | struct kdb_dbbe *be; |
| 688 | register_t intr; |
| 689 | int handled; |
| 690 | int did_stop_cpus; |
| 691 | |
| 692 | be = kdb_dbbe; |
| 693 | if (be == NULL || be->dbbe_trap == NULL) |
| 694 | return (0); |
| 695 | |
| 696 | /* We reenter the debugger through kdb_reenter(). */ |
| 697 | if (kdb_active) |
| 698 | return (0); |
| 699 | |
| 700 | intr = intr_disable(); |
| 701 | |
| 702 | if (!SCHEDULER_STOPPED()) { |
| 703 | #ifdef SMP |
| 704 | other_cpus = all_cpus; |
| 705 | CPU_ANDNOT(&other_cpus, &stopped_cpus); |
| 706 | CPU_CLR(PCPU_GET(cpuid), &other_cpus); |
| 707 | stop_cpus_hard(other_cpus); |
| 708 | #endif |
| 709 | curthread->td_stopsched = 1; |
| 710 | did_stop_cpus = 1; |
| 711 | } else |
| 712 | did_stop_cpus = 0; |
| 713 | |
| 714 | kdb_active++; |
| 715 | |
| 716 | kdb_frame = tf; |
| 717 | |
| 718 | /* Let MD code do its thing first... */ |
| 719 | kdb_cpu_trap(type, code); |
| 720 | |
| 721 | makectx(tf, &kdb_pcb); |
| 722 | kdb_thr_select(curthread); |
| 723 | |
| 724 | cngrab(); |
| 725 | |
| 726 | for (;;) { |
| 727 | handled = be->dbbe_trap(type, code); |
| 728 | if (be == kdb_dbbe) |
| 729 | break; |
| 730 | be = kdb_dbbe; |
| 731 | if (be == NULL || be->dbbe_trap == NULL) |
| 732 | break; |
| 733 | printf("Switching to %s back-end\n", be->dbbe_name); |
| 734 | } |
| 735 | |
| 736 | cnungrab(); |
| 737 | |
| 738 | kdb_active--; |
no test coverage detected