db_machdep.h revision 308418
1139749Simp/*- 2193640Sariff * Mach Operating System 375320Scg * Copyright (c) 1991,1990 Carnegie Mellon University 475320Scg * All Rights Reserved. 575320Scg * 675320Scg * Permission to use, copy, modify and distribute this software and its 775320Scg * documentation is hereby granted, provided that both the copyright 875320Scg * notice and this permission notice appear in all copies of the 975320Scg * software, derivative works or modified versions, and any portions 1075320Scg * thereof, and that both notices appear in supporting documentation. 1175320Scg * 1275320Scg * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 1375320Scg * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 1475320Scg * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 1575320Scg * 1675320Scg * Carnegie Mellon requests users of this software to return to 1775320Scg * 1875320Scg * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 1975320Scg * School of Computer Science 2075320Scg * Carnegie Mellon University 2175320Scg * Pittsburgh PA 15213-3890 2275320Scg * 2375320Scg * any improvements or extensions that they make and grant Carnegie Mellon 2475320Scg * the rights to redistribute these changes. 25170206Sjoel * 26170206Sjoel * $FreeBSD: stable/11/sys/amd64/include/db_machdep.h 308418 2016-11-07 12:10:17Z kib $ 27170206Sjoel */ 28193640Sariff 29193640Sariff#ifndef _MACHINE_DB_MACHDEP_H_ 30193640Sariff#define _MACHINE_DB_MACHDEP_H_ 31164614Sariff 32193640Sariff#include <machine/frame.h> 33193640Sariff#include <machine/trap.h> 34193640Sariff 35164614Sarifftypedef vm_offset_t db_addr_t; /* address - unsigned */ 36193640Sarifftypedef long db_expr_t; /* expression - signed */ 37193640Sariff 38193640Sariff#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_rip) 39193640Sariff 40193640Sariff#define BKPT_INST 0xcc /* breakpoint instruction */ 41193640Sariff#define BKPT_SIZE (1) /* size of breakpoint inst */ 42193640Sariff#define BKPT_SET(inst) (BKPT_INST) 43193640Sariff 44109547Sorion#define BKPT_SKIP \ 45193640Sariffdo { \ 46193640Sariff kdb_frame->tf_rip += 1; \ 47193640Sariff kdb_thrctx->pcb_rip += 1; \ 48193640Sariff} while(0) 4975320Scg 5075320Scg#define FIXUP_PC_AFTER_BREAK \ 51193640Sariffdo { \ 52193640Sariff kdb_frame->tf_rip -= 1; \ 53193640Sariff kdb_thrctx->pcb_rip -= 1; \ 54193640Sariff} while(0); 5575320Scg 56193640Sariff#define db_clear_single_step kdb_cpu_clear_singlestep 5775320Scg#define db_set_single_step kdb_cpu_set_singlestep 5875320Scg 59193640Sariff/* 60193640Sariff * The debug exception type is copied from %dr6 to 'code' and used to 61193640Sariff * disambiguate single step traps. Watchpoints have no special support. 6282180Scg * Our hardware breakpoints are not well integrated with ddb and are too 63193640Sariff * different from watchpoints. ddb treats them as unknown traps with 64110466Sorion * unknown addresses and doesn't turn them off while it is running. 65193640Sariff */ 66110466Sorion#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) 67193640Sariff#define IS_SSTEP_TRAP(type, code) ((type) == T_TRCTRAP && (code) & 0x4000) 68193640Sariff#define IS_WATCHPOINT_TRAP(type, code) 0 69193640Sariff 70193640Sariff#define I_CALL 0xe8 71193640Sariff#define I_CALLI 0xff 72193640Sariff#define I_RET 0xc3 7375320Scg#define I_IRET 0xcf 74193640Sariff 75193640Sariff#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 76193640Sariff#define inst_return(ins) (((ins)&0xff) == I_RET) 77109547Sorion#define inst_call(ins) (((ins)&0xff) == I_CALL || \ 78193640Sariff (((ins)&0xff) == I_CALLI && \ 79193640Sariff ((ins)&0x3800) == 0x1000)) 80109547Sorion#define inst_load(ins) 0 81193640Sariff#define inst_store(ins) 0 82193640Sariff 83110466Sorion/* 84193640Sariff * There no interesting addresses below _kstack = 0xefbfe000. There 85193640Sariff * are small absolute values for GUPROF, but we don't want to see them. 86193640Sariff * Treat "negative" addresses below _kstack as non-small to allow for 87193640Sariff * future reductions of _kstack and to avoid sign extension problems. 88167646Sariff * 89193640Sariff * There is one interesting symbol above -db_maxoff = 0xffff0000, 90193640Sariff * namely _APTD = 0xfffff000. Accepting this would mess up the 91193640Sariff * printing of small negative offsets. The next largest symbol is 92193640Sariff * _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is 93193640Sariff * set to >= 0x400000 - (max stack offset)). 94193640Sariff */ 95193640Sariff#define DB_SMALL_VALUE_MAX 0x7fffffff 96193640Sariff#define DB_SMALL_VALUE_MIN (-0x400001) 97193640Sariff 98193640Sariff#endif /* !_MACHINE_DB_MACHDEP_H_ */ 99193640Sariff