Index: head/sys/arm/include/db_machdep.h =================================================================== --- head/sys/arm/include/db_machdep.h (revision 332562) +++ head/sys/arm/include/db_machdep.h (revision 332563) @@ -1,101 +1,98 @@ /*- * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. * * from: FreeBSD: src/sys/i386/include/db_machdep.h,v 1.16 1999/10/04 * $FreeBSD$ */ #ifndef _MACHINE_DB_MACHDEP_H_ #define _MACHINE_DB_MACHDEP_H_ #include #include #include #define T_BREAKPOINT (1) #define T_WATCHPOINT (2) typedef vm_offset_t db_addr_t; typedef int db_expr_t; #define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_regs.sf_pc) #define BKPT_INST (KERNEL_BREAKPOINT) #define BKPT_SIZE (INSN_SIZE) #define BKPT_SET(inst) (BKPT_INST) #define BKPT_SKIP do { \ kdb_frame->tf_pc += BKPT_SIZE; \ } while (0) #if __ARM_ARCH >= 6 #define db_clear_single_step kdb_cpu_clear_singlestep #define db_set_single_step kdb_cpu_set_singlestep #define db_pc_is_singlestep kdb_cpu_pc_is_singlestep #else #define SOFTWARE_SSTEP 1 #endif #define IS_BREAKPOINT_TRAP(type, code) (type == T_BREAKPOINT) #define IS_WATCHPOINT_TRAP(type, code) (type == T_WATCHPOINT) #define inst_trap_return(ins) (0) /* ldmxx reg, {..., pc} 01800000 stack mode 000f0000 register 0000ffff register list */ /* mov pc, reg 0000000f register */ #define inst_return(ins) (((ins) & 0x0e108000) == 0x08108000 || \ ((ins) & 0x0ff0fff0) == 0x01a0f000 || \ ((ins) & 0x0ffffff0) == 0x012fff10) /* bx */ /* bl ... 00ffffff offset>>2 */ #define inst_call(ins) (((ins) & 0x0f000000) == 0x0b000000) /* b ... 00ffffff offset>>2 */ /* ldr pc, [pc, reg, lsl #2] 0000000f register */ #define inst_branch(ins) (((ins) & 0x0f000000) == 0x0a000000 || \ ((ins) & 0x0fdffff0) == 0x079ff100 || \ ((ins) & 0x0cd0f000) == 0x0490f000 || \ ((ins) & 0x0ffffff0) == 0x012fff30 || /* blx */ \ ((ins) & 0x0de0f000) == 0x0080f000) #define inst_load(ins) (0) #define inst_store(ins) (0) #define next_instr_address(pc, bd) ((bd) ? (pc) : ((pc) + INSN_SIZE)) #define DB_ELFSIZE 32 int db_validate_address(vm_offset_t); u_int branch_taken (u_int insn, db_addr_t pc); -#ifdef __ARMEB__ -#define BYTE_MSF (1) -#endif #endif /* !_MACHINE_DB_MACHDEP_H_ */ Index: head/sys/ddb/db_access.c =================================================================== --- head/sys/ddb/db_access.c (revision 332562) +++ head/sys/ddb/db_access.c (revision 332563) @@ -1,109 +1,106 @@ /*- * SPDX-License-Identifier: MIT-CMU * * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */ /* * Author: David B. Golub, Carnegie Mellon University * Date: 7/90 */ #include __FBSDID("$FreeBSD$"); #include #include +#include #include #include /* * Access unaligned data items on aligned (longword) * boundaries. */ static unsigned db_extend[] = { /* table for sign-extending */ 0, 0xFFFFFF80U, 0xFFFF8000U, 0xFF800000U }; -#ifndef BYTE_MSF -#define BYTE_MSF 0 -#endif - db_expr_t db_get_value(db_addr_t addr, int size, bool is_signed) { char data[sizeof(u_int64_t)]; db_expr_t value; int i; if (db_read_bytes(addr, size, data) != 0) { db_printf("*** error reading from address %llx ***\n", (long long)addr); kdb_reenter(); } value = 0; -#if BYTE_MSF +#if _BYTE_ORDER == _BIG_ENDIAN for (i = 0; i < size; i++) -#else /* BYTE_LSF */ +#else /* _LITTLE_ENDIAN */ for (i = size - 1; i >= 0; i--) #endif { value = (value << 8) + (data[i] & 0xFF); } if (size < 4) { if (is_signed && (value & db_extend[size]) != 0) value |= db_extend[size]; } return (value); } void db_put_value(db_addr_t addr, int size, db_expr_t value) { char data[sizeof(int)]; int i; -#if BYTE_MSF +#if _BYTE_ORDER == _BIG_ENDIAN for (i = size - 1; i >= 0; i--) -#else /* BYTE_LSF */ +#else /* _LITTLE_ENDIAN */ for (i = 0; i < size; i++) #endif { data[i] = value & 0xFF; value >>= 8; } if (db_write_bytes(addr, size, data) != 0) { db_printf("*** error writing to address %llx ***\n", (long long)addr); kdb_reenter(); } } Index: head/sys/mips/include/db_machdep.h =================================================================== --- head/sys/mips/include/db_machdep.h (revision 332562) +++ head/sys/mips/include/db_machdep.h (revision 332563) @@ -1,97 +1,92 @@ /* $OpenBSD: db_machdep.h,v 1.2 1998/09/15 10:50:12 pefo Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1998 Per Fogelstrom, Opsycon AB * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed under OpenBSD by * Per Fogelstrom, Opsycon AB, Sweden. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * JNPR: db_machdep.h,v 1.7 2006/10/16 12:30:34 katta * $FreeBSD$ */ #ifndef _MIPS_DB_MACHDEP_H_ #define _MIPS_DB_MACHDEP_H_ #include #include -#include typedef struct trapframe db_regs_t; extern db_regs_t ddb_regs; /* register state */ typedef vm_offset_t db_addr_t; /* address - unsigned */ typedef register_t db_expr_t; /* expression - signed */ - -#if BYTE_ORDER == _BIG_ENDIAN -#define BYTE_MSF (1) -#endif #define SOFTWARE_SSTEP /* Need software single step */ #define SOFTWARE_SSTEP_EMUL /* next_instr_address() emulates 100% */ db_addr_t next_instr_address(db_addr_t, boolean_t); #define BKPT_SIZE (4) #define BKPT_SET(ins) (MIPS_BREAK_DDB) #define DB_VALID_BREAKPOINT(addr) (((addr) & 3) == 0) #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAK) #define IS_WATCHPOINT_TRAP(type, code) (0) /* XXX mips3 watchpoint */ #define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_regs.pc) #define BKPT_SKIP \ do { \ if((db_get_value(kdb_frame->pc, sizeof(int), FALSE) & \ ~MIPS_BREAK_VAL_MASK) == MIPS_BREAK_INSTR) { \ kdb_frame->pc += BKPT_SIZE; \ kdb_thrctx->pcb_regs.pc += BKPT_SIZE; \ } \ } while (0); /* * Test of instructions to see class. */ #define IT_CALL 0x01 #define IT_BRANCH 0x02 #define IT_LOAD 0x03 #define IT_STORE 0x04 #define inst_branch(i) (db_inst_type(i) == IT_BRANCH) #define inst_trap_return(i) ((i) & 0) #define inst_call(i) (db_inst_type(i) == IT_CALL) #define inst_return(i) ((i) == 0x03e00008) #define inst_load(i) (db_inst_type(i) == IT_LOAD) #define inst_store(i) (db_inst_type(i) == IT_STORE) int db_inst_type(int); db_addr_t branch_taken(int inst, db_addr_t pc); int32_t kdbpeek(int *); int64_t kdbpeekd(int *); #endif /* !_MIPS_DB_MACHDEP_H_ */ Index: head/sys/powerpc/include/db_machdep.h =================================================================== --- head/sys/powerpc/include/db_machdep.h (revision 332562) +++ head/sys/powerpc/include/db_machdep.h (revision 332563) @@ -1,90 +1,88 @@ /*- * Mach Operating System * Copyright (c) 1992 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. * * $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ * $NetBSD: db_machdep.h,v 1.4.22.1 2000/08/05 11:10:43 wiz Exp $ * $FreeBSD$ */ /* * Machine-dependent defines for new kernel debugger. */ #ifndef _POWERPC_DB_MACHDEP_H_ #define _POWERPC_DB_MACHDEP_H_ #include #include #define DB_ELF_SYMBOLS #define DB_ELFSIZE __ELF_WORD_SIZE -#define BYTE_MSF (1) - typedef vm_offset_t db_addr_t; /* address - unsigned */ typedef intptr_t db_expr_t; /* expression - signed */ #define PC_REGS(regs) ((db_addr_t)kdb_thrctx->pcb_lr) #define BKPT_INST 0x7C810808 /* breakpoint instruction */ #define BKPT_SIZE (4) /* size of breakpoint inst */ #define BKPT_SET(inst) (BKPT_INST) #define db_clear_single_step kdb_cpu_clear_singlestep #define db_set_single_step kdb_cpu_set_singlestep #if 0 #define SR_SINGLESTEP 0x400 #define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP) #define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP) #endif #define T_BREAKPOINT 0xffff #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT) #define T_WATCHPOINT 0xeeee #ifdef T_WATCHPOINT #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) #else #define IS_WATCHPOINT_TRAP(type, code) 0 #endif #define M_RTS 0xfc0007fe #define I_RTS 0x4c000020 #define M_BC 0xfc000000 #define I_BC 0x40000000 #define M_B 0xfc000000 #define I_B 0x50000000 #define M_RFI 0xfc0007fe #define I_RFI 0x4c000064 #define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI) #define inst_return(ins) (((ins)&M_RTS) == I_RTS) #define inst_call(ins) (((ins)&M_BC ) == I_BC || \ ((ins)&M_B ) == I_B ) #define inst_load(ins) 0 #define inst_store(ins) 0 #endif /* _POWERPC_DB_MACHDEP_H_ */ Index: head/sys/sparc64/include/db_machdep.h =================================================================== --- head/sys/sparc64/include/db_machdep.h (revision 332562) +++ head/sys/sparc64/include/db_machdep.h (revision 332563) @@ -1,66 +1,64 @@ /*- * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. * * from: FreeBSD: src/sys/i386/include/db_machdep.h,v 1.16 1999/10/04 * $FreeBSD$ */ #ifndef _MACHINE_DB_MACHDEP_H_ #define _MACHINE_DB_MACHDEP_H_ #include #include -#define BYTE_MSF (1) - typedef vm_offset_t db_addr_t; typedef long db_expr_t; #define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_pc) #define BKPT_INST (0x91d03001) #define BKPT_SIZE (4) #define BKPT_SET(inst) (BKPT_INST) #define BKPT_SKIP do { \ kdb_frame->tf_tpc = kdb_frame->tf_tnpc + 4; \ kdb_frame->tf_tnpc += 8; \ } while (0) #define db_clear_single_step kdb_cpu_clear_singlestep #define db_set_single_step kdb_cpu_set_singlestep #define IS_BREAKPOINT_TRAP(type, code) (type == T_BREAKPOINT) #define IS_WATCHPOINT_TRAP(type, code) (0) #define inst_trap_return(ins) (0) #define inst_return(ins) (0) #define inst_call(ins) (0) #define inst_load(ins) (0) #define inst_store(ins) (0) #define DB_ELFSIZE 64 #endif /* !_MACHINE_DB_MACHDEP_H_ */