db_machdep.h revision 1.18 1 1.18 matt /* $NetBSD: db_machdep.h,v 1.18 2002/05/12 23:16:52 matt Exp $ */
2 1.8 cgd
3 1.1 cgd /*
4 1.1 cgd * Mach Operating System
5 1.1 cgd * Copyright (c) 1991,1990 Carnegie Mellon University
6 1.1 cgd * All Rights Reserved.
7 1.1 cgd *
8 1.1 cgd * Permission to use, copy, modify and distribute this software and its
9 1.1 cgd * documentation is hereby granted, provided that both the copyright
10 1.1 cgd * notice and this permission notice appear in all copies of the
11 1.1 cgd * software, derivative works or modified versions, and any portions
12 1.1 cgd * thereof, and that both notices appear in supporting documentation.
13 1.1 cgd *
14 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 1.1 cgd * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 1.1 cgd *
18 1.1 cgd * Carnegie Mellon requests users of this software to return to
19 1.1 cgd *
20 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 1.1 cgd * School of Computer Science
22 1.1 cgd * Carnegie Mellon University
23 1.1 cgd * Pittsburgh PA 15213-3890
24 1.1 cgd *
25 1.1 cgd * any improvements or extensions that they make and grant Carnegie Mellon
26 1.1 cgd * the rights to redistribute these changes.
27 1.1 cgd */
28 1.1 cgd
29 1.1 cgd #ifndef _I386_DB_MACHDEP_H_
30 1.1 cgd #define _I386_DB_MACHDEP_H_
31 1.1 cgd
32 1.1 cgd /*
33 1.1 cgd * Machine-dependent defines for new kernel debugger.
34 1.1 cgd */
35 1.1 cgd
36 1.5 mycroft #include <sys/param.h>
37 1.15 mrg #include <uvm/uvm_extern.h>
38 1.1 cgd #include <machine/trap.h>
39 1.1 cgd
40 1.13 thorpej typedef vaddr_t db_addr_t; /* address - unsigned */
41 1.10 mycroft typedef long db_expr_t; /* expression - signed */
42 1.1 cgd
43 1.6 mycroft typedef struct trapframe db_regs_t;
44 1.18 matt extern db_regs_t ddb_regs; /* register state */
45 1.1 cgd #define DDB_REGS (&ddb_regs)
46 1.1 cgd
47 1.16 lukem #if defined(lint)
48 1.16 lukem #define PC_REGS(regs) ((regs)->tf_eip)
49 1.16 lukem #else
50 1.1 cgd #define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip)
51 1.16 lukem #endif
52 1.1 cgd
53 1.1 cgd #define BKPT_INST 0xcc /* breakpoint instruction */
54 1.1 cgd #define BKPT_SIZE (1) /* size of breakpoint inst */
55 1.1 cgd #define BKPT_SET(inst) (BKPT_INST)
56 1.1 cgd
57 1.11 gwr #define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_eip -= BKPT_SIZE)
58 1.1 cgd
59 1.3 mycroft #define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T)
60 1.3 mycroft #define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T)
61 1.1 cgd
62 1.1 cgd #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
63 1.3 mycroft #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_TRCTRAP && (code) & 15)
64 1.1 cgd
65 1.1 cgd #define I_CALL 0xe8
66 1.1 cgd #define I_CALLI 0xff
67 1.1 cgd #define I_RET 0xc3
68 1.1 cgd #define I_IRET 0xcf
69 1.1 cgd
70 1.1 cgd #define inst_trap_return(ins) (((ins)&0xff) == I_IRET)
71 1.1 cgd #define inst_return(ins) (((ins)&0xff) == I_RET)
72 1.1 cgd #define inst_call(ins) (((ins)&0xff) == I_CALL || \
73 1.1 cgd (((ins)&0xff) == I_CALLI && \
74 1.1 cgd ((ins)&0x3800) == 0x1000))
75 1.1 cgd #define inst_load(ins) 0
76 1.1 cgd #define inst_store(ins) 0
77 1.1 cgd
78 1.1 cgd /* access capability and access macros */
79 1.1 cgd
80 1.1 cgd #define DB_ACCESS_LEVEL 2 /* access any space */
81 1.1 cgd #define DB_CHECK_ACCESS(addr,size,task) \
82 1.1 cgd db_check_access(addr,size,task)
83 1.1 cgd #define DB_PHYS_EQ(task1,addr1,task2,addr2) \
84 1.1 cgd db_phys_eq(task1,addr1,task2,addr2)
85 1.1 cgd #define DB_VALID_KERN_ADDR(addr) \
86 1.1 cgd ((addr) >= VM_MIN_KERNEL_ADDRESS && \
87 1.1 cgd (addr) < VM_MAX_KERNEL_ADDRESS)
88 1.1 cgd #define DB_VALID_ADDRESS(addr,user) \
89 1.1 cgd ((!(user) && DB_VALID_KERN_ADDR(addr)) || \
90 1.3 mycroft ((user) && (addr) < VM_MAX_ADDRESS))
91 1.1 cgd
92 1.9 christos #if 0
93 1.13 thorpej boolean_t db_check_access __P((vaddr_t, int, task_t));
94 1.13 thorpej boolean_t db_phys_eq __P((task_t, vaddr_t, task_t, vaddr_t));
95 1.9 christos #endif
96 1.1 cgd
97 1.1 cgd /* macros for printing OS server dependent task name */
98 1.1 cgd
99 1.1 cgd #define DB_TASK_NAME(task) db_task_name(task)
100 1.1 cgd #define DB_TASK_NAME_TITLE "COMMAND "
101 1.1 cgd #define DB_TASK_NAME_LEN 23
102 1.1 cgd #define DB_NULL_TASK_NAME "? "
103 1.1 cgd
104 1.12 thorpej /*
105 1.12 thorpej * Constants for KGDB.
106 1.12 thorpej */
107 1.12 thorpej typedef long kgdb_reg_t;
108 1.17 sommerfe #define KGDB_NUMREGS 16
109 1.12 thorpej #define KGDB_BUFLEN 512
110 1.12 thorpej
111 1.9 christos #if 0
112 1.1 cgd void db_task_name(/* task_t */);
113 1.9 christos #endif
114 1.1 cgd
115 1.1 cgd /* macro for checking if a thread has used floating-point */
116 1.1 cgd
117 1.1 cgd #define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0)
118 1.9 christos
119 1.9 christos int kdb_trap __P((int, int, db_regs_t *));
120 1.12 thorpej
121 1.12 thorpej /*
122 1.14 thorpej * We use either a.out or Elf32 symbols in DDB.
123 1.12 thorpej */
124 1.12 thorpej #define DB_AOUT_SYMBOLS
125 1.14 thorpej #define DB_ELF_SYMBOLS
126 1.14 thorpej #define DB_ELFSIZE 32
127 1.1 cgd
128 1.1 cgd #endif /* _I386_DB_MACHDEP_H_ */
129