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: stable/11/sys/amd64/include/db_machdep.h 338691 2018-09-14 23:21:52Z jhb $ 27 */ 28 29#ifndef _MACHINE_DB_MACHDEP_H_ 30#define _MACHINE_DB_MACHDEP_H_ 31 32#include <machine/frame.h> 33#include <machine/reg.h> 34#include <machine/trap.h> 35 36typedef vm_offset_t db_addr_t; /* address - unsigned */ 37typedef long db_expr_t; /* expression - signed */ 38 39#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_rip) 40 41#define BKPT_INST 0xcc /* breakpoint instruction */ 42#define BKPT_SIZE (1) /* size of breakpoint inst */ 43#define BKPT_SET(inst) (BKPT_INST) 44 45#define BKPT_SKIP \ 46do { \ 47 kdb_frame->tf_rip += 1; \ 48 kdb_thrctx->pcb_rip += 1; \ 49} while(0) 50 51#define FIXUP_PC_AFTER_BREAK \ 52do { \ 53 kdb_frame->tf_rip -= 1; \ 54 kdb_thrctx->pcb_rip -= 1; \ 55} while(0); 56 57#define db_clear_single_step kdb_cpu_clear_singlestep 58#define db_set_single_step kdb_cpu_set_singlestep 59 60/* 61 * The debug exception type is copied from %dr6 to 'code' and used to 62 * disambiguate single step traps. Watchpoints have no special support. 63 * Our hardware breakpoints are not well integrated with ddb and are too 64 * different from watchpoints. ddb treats them as unknown traps with 65 * unknown addresses and doesn't turn them off while it is running. 66 */ 67#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) 68#define IS_SSTEP_TRAP(type, code) \ 69 ((type) == T_TRCTRAP && (code) & DBREG_DR6_BS) 70#define IS_WATCHPOINT_TRAP(type, code) 0 71 72#define I_CALL 0xe8 73#define I_CALLI 0xff 74#define I_RET 0xc3 75#define I_IRET 0xcf 76 77#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 78#define inst_return(ins) (((ins)&0xff) == I_RET) 79#define inst_call(ins) (((ins)&0xff) == I_CALL || \ 80 (((ins)&0xff) == I_CALLI && \ 81 ((ins)&0x3800) == 0x1000)) 82#define inst_load(ins) 0 83#define inst_store(ins) 0 84 85/* 86 * There no interesting addresses below _kstack = 0xefbfe000. There 87 * are small absolute values for GUPROF, but we don't want to see them. 88 * Treat "negative" addresses below _kstack as non-small to allow for 89 * future reductions of _kstack and to avoid sign extension problems. 90 * 91 * There is one interesting symbol above -db_maxoff = 0xffff0000, 92 * namely _APTD = 0xfffff000. Accepting this would mess up the 93 * printing of small negative offsets. The next largest symbol is 94 * _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is 95 * set to >= 0x400000 - (max stack offset)). 96 */ 97#define DB_SMALL_VALUE_MAX 0x7fffffff 98#define DB_SMALL_VALUE_MIN (-0x400001) 99 100#endif /* !_MACHINE_DB_MACHDEP_H_ */ 101