2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
54 * Interface to new debugger.
57 #include <platforms.h>
58 #include <time_stamp.h>
59 #include <mach_mp_debug.h>
60 #include <mach_ldebug.h>
62 #include <kern/cpu_number.h>
63 #include <kern/kern_types.h>
64 #include <kern/misc_protos.h>
67 #include <i386/thread.h>
68 #include <i386/db_machdep.h>
70 #include <i386/trap.h>
71 #include <i386/setjmp.h>
72 #include <i386/pmap.h>
73 #include <i386/misc_protos.h>
75 #include <mach/vm_param.h>
76 #include <vm/vm_map.h>
77 #include <kern/thread.h>
78 #include <kern/task.h>
80 #include <ddb/db_command.h>
81 #include <ddb/db_task_thread.h>
82 #include <ddb/db_run.h>
83 #include <ddb/db_trap.h>
84 #include <ddb/db_output.h>
85 #include <ddb/db_access.h>
86 #include <ddb/db_sym.h>
87 #include <ddb/db_break.h>
88 #include <ddb/db_watch.h>
91 int db_pass_thru
[NCPUS
];
92 struct i386_saved_state
*i386_last_saved_statep
;
93 struct i386_saved_state i386_nested_saved_state
;
94 unsigned i386_last_kdb_sp
;
96 vm_offset_t db_stacks
[NCPUS
];
98 extern thread_act_t db_default_act
;
101 extern int masked_state_cnt
[];
102 #endif /* MACH_MP_DEBUG */
105 * Enter KDB through a keyboard trap.
106 * We show the registers as of the keyboard interrupt
107 * instead of those at its call to KDB.
116 struct i386_interrupt_state
*is
;
119 extern char * trap_type
[];
120 extern int TRAP_TYPES
;
124 extern void kdbprinttrap(
129 extern void kdb_kentry(
130 struct int_regs
*int_regs
);
131 extern int db_user_to_kernel_address(
136 extern void db_write_bytes_user_space(
141 extern int db_search_null(
147 extern int kdb_enter(int);
148 extern void kdb_leave(void);
149 extern void lock_kdb(void);
150 extern void unlock_kdb(void);
153 * kdb_trap - field a TRACE or BPT trap
157 extern jmp_buf_t
*db_recover
;
158 spl_t saved_ipl
[NCPUS
]; /* just to know what IPL was before trap */
159 struct i386_saved_state
*saved_state
[NCPUS
];
162 * Translate the state saved in a task state segment into an
163 * exception frame. Since we "know" we always want the state
164 * in a ktss, we hard-wire that in, rather than indexing the gdt
165 * with tss_sel to derive a pointer to the desired tss.
170 struct i386_saved_state
*regs
)
172 extern struct i386_tss ktss
;
173 int mycpu
= cpu_number();
174 struct i386_tss
*tss
;
177 tss
= &ktss
; /* XXX */
178 #else /* NCPUS > 1 */
179 tss
= mp_ktss
[mycpu
]; /* XXX */
180 #endif /* NCPUS > 1 */
183 * ddb will overwrite whatever's in esp, so put esp0 elsewhere, too.
185 regs
->esp
= tss
->esp0
;
186 regs
->efl
= tss
->eflags
;
187 regs
->eip
= tss
->eip
;
188 regs
->trapno
= tss
->ss0
; /* XXX */
189 regs
->err
= tss
->esp0
; /* XXX */
190 regs
->eax
= tss
->eax
;
191 regs
->ecx
= tss
->ecx
;
192 regs
->edx
= tss
->edx
;
193 regs
->ebx
= tss
->ebx
;
194 regs
->uesp
= tss
->esp
;
195 regs
->ebp
= tss
->ebp
;
196 regs
->esi
= tss
->esi
;
197 regs
->edi
= tss
->edi
;
207 * Compose a call to the debugger from the saved state in regs. (No
208 * reason not to do this in C.)
212 struct i386_saved_state
*regs
)
219 return (kdb_trap(type
, code
, regs
));
226 struct i386_saved_state
*regs
)
229 boolean_t trap_from_user
;
233 case T_DEBUG
: /* single_step */
235 extern int dr_addr
[];
239 if (status
& 0xf) { /* hmm hdw break */
240 addr
= status
& 0x8 ? dr_addr
[3] :
241 status
& 0x4 ? dr_addr
[2] :
242 status
& 0x2 ? dr_addr
[1] :
245 db_single_step_cmd(addr
, 0, 1, "p");
248 case T_INT3
: /* breakpoint */
249 case T_WATCHPOINT
: /* watchpoint */
250 case -1: /* keyboard interrupt */
255 i386_nested_saved_state
= *regs
;
256 db_printf("Caught ");
257 if (type
< 0 || type
> TRAP_TYPES
)
258 db_printf("type %d", type
);
260 db_printf("%s", trap_type
[type
]);
261 db_printf(" trap, code = %x, pc = %x\n",
267 kdbprinttrap(type
, code
, (int *)®s
->eip
, regs
->uesp
);
271 disable_preemption();
272 #endif /* NCPUS > 1 */
274 saved_ipl
[cpu_number()] = s
;
275 saved_state
[cpu_number()] = regs
;
277 i386_last_saved_statep
= regs
;
278 i386_last_kdb_sp
= (unsigned) &type
;
281 if (!kdb_enter(regs
->eip
))
283 #endif /* NCPUS > 1 */
285 /* Should switch to kdb's own stack here. */
287 if (!IS_USER_TRAP(regs
, &etext
)) {
288 bzero((char *)&ddb_regs
, sizeof (ddb_regs
));
289 *(struct i386_saved_state_from_kernel
*)&ddb_regs
=
290 *(struct i386_saved_state_from_kernel
*)regs
;
291 trap_from_user
= FALSE
;
295 trap_from_user
= TRUE
;
297 if (!trap_from_user
) {
299 * Kernel mode - esp and ss not saved
301 ddb_regs
.uesp
= (int)®s
->uesp
; /* kernel stack pointer */
302 ddb_regs
.ss
= KERNEL_DS
;
306 db_task_trap(type
, code
, trap_from_user
);
309 regs
->eip
= ddb_regs
.eip
;
310 regs
->efl
= ddb_regs
.efl
;
311 regs
->eax
= ddb_regs
.eax
;
312 regs
->ecx
= ddb_regs
.ecx
;
313 regs
->edx
= ddb_regs
.edx
;
314 regs
->ebx
= ddb_regs
.ebx
;
315 if (trap_from_user
) {
317 * user mode - saved esp and ss valid
319 regs
->uesp
= ddb_regs
.uesp
; /* user stack pointer */
320 regs
->ss
= ddb_regs
.ss
& 0xffff; /* user stack segment */
322 regs
->ebp
= ddb_regs
.ebp
;
323 regs
->esi
= ddb_regs
.esi
;
324 regs
->edi
= ddb_regs
.edi
;
325 regs
->es
= ddb_regs
.es
& 0xffff;
326 regs
->cs
= ddb_regs
.cs
& 0xffff;
327 regs
->ds
= ddb_regs
.ds
& 0xffff;
328 regs
->fs
= ddb_regs
.fs
& 0xffff;
329 regs
->gs
= ddb_regs
.gs
& 0xffff;
331 if ((type
== T_INT3
) &&
332 (db_get_task_value(regs
->eip
,
335 db_target_space(current_act(),
338 regs
->eip
+= BKPT_SIZE
;
343 #endif /* NCPUS > 1 */
345 saved_state
[cpu_number()] = 0;
348 masked_state_cnt
[cpu_number()] = 0;
349 #endif /* MACH_MP_DEBUG */
353 #endif /* NCPUS > 1 */
357 /* Allow continue to upper layers of exception handling if
358 * trap was not a debugging trap.
361 if (trap_from_user
&& type
!= T_DEBUG
&& type
!= T_INT3
362 && type
!= T_WATCHPOINT
)
369 * Enter KDB through a keyboard trap.
370 * We show the registers as of the keyboard interrupt
371 * instead of those at its call to KDB.
378 struct int_regs
*int_regs
)
381 boolean_t trap_from_user
;
382 struct i386_interrupt_state
*is
= int_regs
->is
;
383 struct i386_saved_state regs
;
389 if (IS_USER_TRAP(is
, &etext
))
391 regs
.uesp
= ((int *)(is
+1))[0];
392 regs
.ss
= ((int *)(is
+1))[1];
396 regs
.uesp
= (int)(is
+1);
404 regs
.ebx
= int_regs
->ebx
;
405 regs
.ebp
= int_regs
->ebp
;
406 regs
.esi
= int_regs
->esi
;
407 regs
.edi
= int_regs
->edi
;
410 regs
.fs
= int_regs
->fs
;
411 regs
.gs
= int_regs
->gs
;
414 disable_preemption();
415 #endif /* NCPUS > 1 */
417 saved_state
[cpu_number()] = ®s
;
420 if (!kdb_enter(regs
.eip
))
422 #endif /* NCPUS > 1 */
424 bcopy((char *)®s
, (char *)&ddb_regs
, sizeof (ddb_regs
));
425 trap_from_user
= IS_USER_TRAP(&ddb_regs
, &etext
);
428 db_task_trap(-1, 0, trap_from_user
);
431 if (trap_from_user
) {
432 ((int *)(is
+1))[0] = ddb_regs
.uesp
;
433 ((int *)(is
+1))[1] = ddb_regs
.ss
& 0xffff;
435 is
->efl
= ddb_regs
.efl
;
436 is
->cs
= ddb_regs
.cs
& 0xffff;
437 is
->eip
= ddb_regs
.eip
;
438 is
->eax
= ddb_regs
.eax
;
439 is
->ecx
= ddb_regs
.ecx
;
440 is
->edx
= ddb_regs
.edx
;
441 int_regs
->ebx
= ddb_regs
.ebx
;
442 int_regs
->ebp
= ddb_regs
.ebp
;
443 int_regs
->esi
= ddb_regs
.esi
;
444 int_regs
->edi
= ddb_regs
.edi
;
445 is
->ds
= ddb_regs
.ds
& 0xffff;
446 is
->es
= ddb_regs
.es
& 0xffff;
447 int_regs
->fs
= ddb_regs
.fs
& 0xffff;
448 int_regs
->gs
= ddb_regs
.gs
& 0xffff;
453 #endif /* NCPUS > 1 */
454 saved_state
[cpu_number()] = 0;
458 #endif /* NCPUS > 1 */
475 if (type
< 0 || type
> TRAP_TYPES
)
476 db_printf("type %d", type
);
478 db_printf("%s", trap_type
[type
]);
479 db_printf(" trap, code=%x eip@%x = %x esp=%x\n",
480 code
, pc
, *(int *)pc
, sp
);
481 db_run_mode
= STEP_CONTINUE
;
485 db_user_to_kernel_address(
491 register pt_entry_t
*ptp
;
493 ptp
= pmap_pte(task
->map
->pmap
, addr
);
494 if (ptp
== PT_ENTRY_NULL
|| (*ptp
& INTEL_PTE_VALID
) == 0) {
496 db_printf("\nno memory is assigned to address %08x\n", addr
);
502 *kaddr
= (unsigned)ptetokv(*ptp
) + (addr
& (INTEL_PGBYTES
-1));
507 * Read bytes from kernel address space for debugger.
522 if (task
== kernel_task
|| task
== TASK_NULL
) {
523 while (--size
>= 0) {
524 if (addr
++ > VM_MAX_KERNEL_ADDRESS
) {
525 db_printf("\nbad address %x\n", addr
);
534 if (db_user_to_kernel_address(task
, addr
, &kern_addr
, 1) < 0)
536 src
= (char *)kern_addr
;
537 n
= intel_trunc_page(addr
+INTEL_PGBYTES
) - addr
;
548 * Write bytes to kernel address space for debugger.
560 register pt_entry_t
*ptep0
= 0;
561 pt_entry_t oldmap0
= 0;
563 register pt_entry_t
*ptep1
= 0;
564 pt_entry_t oldmap1
= 0;
567 if (task
&& task
!= kernel_task
) {
568 db_write_bytes_user_space(addr
, size
, data
, task
);
573 if (addr
>= VM_MIN_KERNEL_LOADED_ADDRESS
) {
574 db_write_bytes_user_space(addr
, size
, data
, kernel_task
);
578 if (addr
>= VM_MIN_KERNEL_ADDRESS
&&
579 addr
<= (vm_offset_t
)&etext
)
581 ptep0
= pmap_pte(kernel_pmap
, addr
);
583 *ptep0
|= INTEL_PTE_WRITE
;
585 addr1
= i386_trunc_page(addr
+ size
- 1);
586 if (i386_trunc_page(addr
) != addr1
) {
587 /* data crosses a page boundary */
589 ptep1
= pmap_pte(kernel_pmap
, addr1
);
591 *ptep1
|= INTEL_PTE_WRITE
;
598 while (--size
>= 0) {
599 if (addr
++ > VM_MAX_KERNEL_ADDRESS
) {
600 db_printf("\nbad address %x\n", addr
);
617 db_write_bytes_user_space(
628 if (db_user_to_kernel_address(task
, addr
, &kern_addr
, 1) < 0)
630 dst
= (char *)kern_addr
;
631 n
= intel_trunc_page(addr
+INTEL_PGBYTES
) - addr
;
650 if (task
== kernel_task
|| task
== TASK_NULL
) {
651 if (kernel_task
== TASK_NULL
)
654 } else if (task
== TASK_NULL
) {
655 if (current_act() == THR_ACT_NULL
)
657 task
= current_act()->task
;
660 if (db_user_to_kernel_address(task
, addr
, &kern_addr
, 0) < 0)
662 n
= intel_trunc_page(addr
+INTEL_PGBYTES
) - addr
;
678 unsigned kern_addr1
, kern_addr2
;
680 if ((addr1
& (INTEL_PGBYTES
-1)) != (addr2
& (INTEL_PGBYTES
-1)))
682 if (task1
== TASK_NULL
) {
683 if (current_act() == THR_ACT_NULL
)
685 task1
= current_act()->task
;
687 if (db_user_to_kernel_address(task1
, addr1
, &kern_addr1
, 0) < 0 ||
688 db_user_to_kernel_address(task2
, addr2
, &kern_addr2
, 0) < 0)
690 return(kern_addr1
== kern_addr2
);
693 #define DB_USER_STACK_ADDR (VM_MIN_KERNEL_ADDRESS)
694 #define DB_NAME_SEARCH_LIMIT (DB_USER_STACK_ADDR-(INTEL_PGBYTES*3))
704 register unsigned vaddr
;
705 register unsigned *kaddr
;
707 kaddr
= (unsigned *)*skaddr
;
708 for (vaddr
= *svaddr
; vaddr
> evaddr
; vaddr
-= sizeof(unsigned)) {
709 if (vaddr
% INTEL_PGBYTES
== 0) {
710 vaddr
-= sizeof(unsigned);
711 if (db_user_to_kernel_address(task
, vaddr
, skaddr
, 0) < 0)
713 kaddr
= (unsigned *)*skaddr
;
715 vaddr
-= sizeof(unsigned);
718 if ((*kaddr
== 0) ^ (flag
== 0)) {
720 *skaddr
= (unsigned)kaddr
;
733 unsigned vaddr
, kaddr
;
735 vaddr
= DB_USER_STACK_ADDR
;
739 * skip nulls at the end
741 if (db_search_null(task
, &vaddr
, DB_NAME_SEARCH_LIMIT
, &kaddr
, 0) < 0) {
742 db_printf(DB_NULL_TASK_NAME
);
746 * search start of args
748 if (db_search_null(task
, &vaddr
, DB_NAME_SEARCH_LIMIT
, &kaddr
, 1) < 0) {
749 db_printf(DB_NULL_TASK_NAME
);
753 n
= DB_TASK_NAME_LEN
-1;
754 p
= (char *)kaddr
+ sizeof(unsigned);
755 for (vaddr
+= sizeof(int); vaddr
< DB_USER_STACK_ADDR
&& n
> 0;
757 if (vaddr
% INTEL_PGBYTES
== 0) {
758 (void)db_user_to_kernel_address(task
, vaddr
, &kaddr
, 0);
761 db_printf("%c", (*p
< ' ' || *p
> '~')? ' ': *p
);
763 while (n
-- >= 0) /* compare with >= 0 for one more space */
770 db_machdep_init(void)
772 db_stacks
[0] = (vm_offset_t
)(db_stack_store
+
773 INTSTACK_SIZE
- sizeof (natural_t
));
774 dbtss
.esp0
= (int)(db_task_stack_store
+
775 INTSTACK_SIZE
- sizeof (natural_t
));
776 dbtss
.esp
= dbtss
.esp0
;
777 dbtss
.eip
= (int)&db_task_start
;
780 #else /* NCPUS > 1 */
783 * Code used to synchronize kdb among all cpus, one active at a time, switch
784 * from on to another using kdb_on! #cpu or cpu #cpu
787 decl_simple_lock_data(, kdb_lock
) /* kdb lock */
789 #define db_simple_lock_init(l, e) hw_lock_init(&((l)->interlock))
790 #define db_simple_lock_try(l) hw_lock_try(&((l)->interlock))
791 #define db_simple_unlock(l) hw_lock_unlock(&((l)->interlock))
793 int kdb_cpu
= -1; /* current cpu running kdb */
795 int kdb_is_slave
[NCPUS
];
796 int kdb_active
[NCPUS
];
797 volatile unsigned int cpus_holding_bkpts
; /* counter for number of cpus holding
798 breakpoints (ie: cpus that did not
799 insert back breakpoints) */
800 extern boolean_t db_breakpoints_inserted
;
803 db_machdep_init(void)
807 db_simple_lock_init(&kdb_lock
, ETAP_MISC_KDB
);
808 for (c
= 0; c
< NCPUS
; ++c
) {
809 db_stacks
[c
] = (vm_offset_t
) (db_stack_store
+
810 (INTSTACK_SIZE
* (c
+ 1)) - sizeof (natural_t
));
811 if (c
== master_cpu
) {
812 dbtss
.esp0
= (int)(db_task_stack_store
+
813 (INTSTACK_SIZE
* (c
+ 1)) - sizeof (natural_t
));
814 dbtss
.esp
= dbtss
.esp0
;
815 dbtss
.eip
= (int)&db_task_start
;
817 * The TSS for the debugging task on each slave CPU
818 * is set up in mp_desc_init().
825 * Called when entering kdb:
826 * Takes kdb lock. If if we were called remotely (slave state) we just
827 * wait for kdb_cpu to be equal to cpu_number(). Otherwise enter kdb if
828 * not active on another cpu.
829 * If db_pass_thru[cpu_number()] > 0, then kdb can't stop now.
839 disable_preemption();
840 #endif /* NCPUS > 1 */
842 my_cpu
= cpu_number();
844 if (db_pass_thru
[my_cpu
]) {
849 kdb_active
[my_cpu
]++;
853 db_printf("kdb_enter: cpu %d, is_slave %d, kdb_cpu %d, run mode %d pc %x (%x) holds %d\n",
854 my_cpu
, kdb_is_slave
[my_cpu
], kdb_cpu
,
855 db_run_mode
, pc
, *(int *)pc
, cpus_holding_bkpts
);
856 if (db_breakpoints_inserted
)
857 cpus_holding_bkpts
++;
858 if (kdb_cpu
== -1 && !kdb_is_slave
[my_cpu
]) {
860 remote_kdb(); /* stop other cpus */
862 } else if (kdb_cpu
== my_cpu
)
870 #endif /* NCPUS > 1 */
879 boolean_t wait
= FALSE
;
882 disable_preemption();
883 #endif /* NCPUS > 1 */
885 my_cpu
= cpu_number();
887 if (db_run_mode
== STEP_CONTINUE
) {
891 if (db_breakpoints_inserted
)
892 cpus_holding_bkpts
--;
893 if (kdb_is_slave
[my_cpu
])
894 kdb_is_slave
[my_cpu
]--;
896 db_printf("kdb_leave: cpu %d, kdb_cpu %d, run_mode %d pc %x (%x) holds %d\n",
897 my_cpu
, kdb_cpu
, db_run_mode
,
898 ddb_regs
.eip
, *(int *)ddb_regs
.eip
,
902 kdb_active
[my_cpu
]--;
906 #endif /* NCPUS > 1 */
909 while(cpus_holding_bkpts
);
918 extern void kdb_console(void);
921 disable_preemption();
922 #endif /* NCPUS > 1 */
924 my_cpu
= cpu_number();
928 if (kdb_cpu
!= -1 && kdb_cpu
!= my_cpu
) {
931 if (db_simple_lock_try(&kdb_lock
)) {
932 if (kdb_cpu
== -1 || kdb_cpu
== my_cpu
)
934 db_simple_unlock(&kdb_lock
);
940 #endif /* NCPUS > 1 */
944 extern unsigned old_time_stamp
;
945 #endif /* TIME_STAMP */
950 db_simple_unlock(&kdb_lock
);
953 #endif /* TIME_STAMP */
958 #define KDB_SAVE(type, name) extern type name; type name##_save = name
959 #define KDB_RESTORE(name) name = name##_save
961 #define KDB_SAVE(type, name) extern type name; type name/**/_save = name
962 #define KDB_RESTORE(name) name = name/**/_save
963 #endif /* __STDC__ */
965 #define KDB_SAVE_CTXT() \
966 KDB_SAVE(int, db_run_mode); \
967 KDB_SAVE(boolean_t, db_sstep_print); \
968 KDB_SAVE(int, db_loop_count); \
969 KDB_SAVE(int, db_call_depth); \
970 KDB_SAVE(int, db_inst_count); \
971 KDB_SAVE(int, db_last_inst_count); \
972 KDB_SAVE(int, db_load_count); \
973 KDB_SAVE(int, db_store_count); \
974 KDB_SAVE(boolean_t, db_cmd_loop_done); \
975 KDB_SAVE(jmp_buf_t *, db_recover); \
976 KDB_SAVE(db_addr_t, db_dot); \
977 KDB_SAVE(db_addr_t, db_last_addr); \
978 KDB_SAVE(db_addr_t, db_prev); \
979 KDB_SAVE(db_addr_t, db_next); \
980 KDB_SAVE(db_regs_t, ddb_regs);
982 #define KDB_RESTORE_CTXT() \
983 KDB_RESTORE(db_run_mode); \
984 KDB_RESTORE(db_sstep_print); \
985 KDB_RESTORE(db_loop_count); \
986 KDB_RESTORE(db_call_depth); \
987 KDB_RESTORE(db_inst_count); \
988 KDB_RESTORE(db_last_inst_count); \
989 KDB_RESTORE(db_load_count); \
990 KDB_RESTORE(db_store_count); \
991 KDB_RESTORE(db_cmd_loop_done); \
992 KDB_RESTORE(db_recover); \
993 KDB_RESTORE(db_dot); \
994 KDB_RESTORE(db_last_addr); \
995 KDB_RESTORE(db_prev); \
996 KDB_RESTORE(db_next); \
997 KDB_RESTORE(ddb_regs);
1000 * switch to another cpu
1008 if (cpu
< 0 || cpu
>= NCPUS
|| !kdb_active
[cpu
])
1010 db_set_breakpoints();
1011 db_set_watchpoints();
1015 db_clear_breakpoints();
1016 db_clear_watchpoints();
1018 if (kdb_cpu
== -1) {/* someone continued */
1019 kdb_cpu
= cpu_number();
1020 db_continue_cmd(0, 0, 0, "");
1024 #endif /* NCPUS > 1 */
1028 boolean_t have_addr
,
1032 boolean_t reboot
= TRUE
;
1036 while ((c
= *cp
++) != 0) {
1037 if (c
== 'r') /* reboot */
1039 if (c
== 'h') /* halt */
1042 halt_all_cpus(reboot
);