| Commit | Line | Data |
|---|---|---|
| d7f50089 YY |
1 | /*- |
| 2 | * Mach Operating System | |
| 3 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
| 4 | * All Rights Reserved. | |
| 5 | * | |
| 6 | * Permission to use, copy, modify and distribute this software and its | |
| 7 | * documentation is hereby granted, provided that both the copyright | |
| 8 | * notice and this permission notice appear in all copies of the | |
| 9 | * software, derivative works or modified versions, and any portions | |
| 10 | * thereof, and that both notices appear in supporting documentation. | |
| 11 | * | |
| 12 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
| 13 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
| 14 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
| 15 | * | |
| 16 | * Carnegie Mellon requests users of this software to return to | |
| 17 | * | |
| 18 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
| 19 | * School of Computer Science | |
| 20 | * Carnegie Mellon University | |
| 21 | * Pittsburgh PA 15213-3890 | |
| 22 | * | |
| 23 | * any improvements or extensions that they make and grant Carnegie Mellon | |
| 24 | * the rights to redistribute these changes. | |
| 25 | * | |
| 26 | * $FreeBSD: src/sys/amd64/include/db_machdep.h,v 1.22 2005/01/05 20:17:20 imp Exp $ | |
| d7f50089 YY |
27 | */ |
| 28 | ||
| 29 | #ifndef _CPU_DB_MACHDEP_H_ | |
| 30 | #define _CPU_DB_MACHDEP_H_ | |
| 31 | ||
| 32 | #include <cpu/frame.h> | |
| 33 | #include <cpu/trap.h> | |
| 34 | ||
| c1543a89 | 35 | #define x86_64_saved_state trapframe |
| d7f50089 YY |
36 | |
| 37 | typedef vm_offset_t db_addr_t; /* address - unsigned */ | |
| 38 | typedef long db_expr_t; /* expression - signed */ | |
| 39 | ||
| c1543a89 | 40 | typedef struct x86_64_saved_state db_regs_t; |
| d7f50089 YY |
41 | |
| 42 | #ifdef _KERNEL | |
| 43 | extern db_regs_t ddb_regs; /* register state */ | |
| 44 | #define DDB_REGS (&ddb_regs) | |
| 45 | ||
| 46 | extern db_addr_t PC_REGS(db_regs_t *regs); | |
| 47 | extern db_addr_t SP_REGS(db_regs_t *regs); | |
| 48 | extern db_addr_t BP_REGS(db_regs_t *regs); | |
| 49 | ||
| 50 | #endif | |
| 51 | ||
| 52 | #define BKPT_INST 0xcc /* breakpoint instruction */ | |
| 53 | #define BKPT_SIZE (1) /* size of breakpoint inst */ | |
| 54 | #define BKPT_SET(inst) (BKPT_INST) | |
| 55 | ||
| 56 | #define FIXUP_PC_AFTER_BREAK ddb_regs.tf_rip -= 1; | |
| 57 | ||
| 58 | #define db_clear_single_step(regs) ((regs)->tf_rflags &= ~PSL_T) | |
| 59 | #define db_set_single_step(regs) ((regs)->tf_rflags |= PSL_T) | |
| 60 | ||
| 61 | #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) | |
| 62 | /* | |
| 63 | * Watchpoints are not supported. The debug exception type is in %dr6 | |
| 64 | * and not yet in the args to this macro. | |
| 65 | */ | |
| 66 | #define IS_WATCHPOINT_TRAP(type, code) 0 | |
| 67 | ||
| 68 | #define I_CALL 0xe8 | |
| 69 | #define I_CALLI 0xff | |
| 70 | #define I_RET 0xc3 | |
| 71 | #define I_IRET 0xcf | |
| 72 | ||
| 73 | #define inst_trap_return(ins) (((ins)&0xff) == I_IRET) | |
| 74 | #define inst_return(ins) (((ins)&0xff) == I_RET) | |
| 75 | #define inst_call(ins) (((ins)&0xff) == I_CALL || \ | |
| 76 | (((ins)&0xff) == I_CALLI && \ | |
| 77 | ((ins)&0x3800) == 0x1000)) | |
| 78 | #define inst_load(ins) 0 | |
| 79 | #define inst_store(ins) 0 | |
| 80 | ||
| 81 | /* | |
| 82 | * There no interesting addresses below _kstack = 0xefbfe000. There | |
| 83 | * are small absolute values for GUPROF, but we don't want to see them. | |
| 84 | * Treat "negative" addresses below _kstack as non-small to allow for | |
| 85 | * future reductions of _kstack and to avoid sign extension problems. | |
| 86 | * | |
| 87 | * There is one interesting symbol above -db_maxoff = 0xffff0000, | |
| 88 | * namely _APTD = 0xfffff000. Accepting this would mess up the | |
| 89 | * printing of small negative offsets. The next largest symbol is | |
| 90 | * _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is | |
| 91 | * set to >= 0x400000 - (max stack offset)). | |
| 92 | */ | |
| 93 | #define DB_SMALL_VALUE_MAX 0x7fffffff | |
| 94 | #define DB_SMALL_VALUE_MIN (-0x400001) | |
| 95 | ||
| 96 | #endif /* !_CPU_DB_MACHDEP_H_ */ |