From f4c36297ec3b30adad9e251b23ba88781e724d32 Mon Sep 17 00:00:00 2001 From: mpi Date: Sun, 30 Apr 2017 13:04:49 +0000 Subject: [PATCH] Unifdef KGDB. It doesn't compile und hasn't been working during the last decade. ok kettenis@, deraadt@ --- sys/arch/alpha/alpha/dec_1000a.c | 15 +- sys/arch/alpha/alpha/dec_kn300.c | 15 +- sys/arch/alpha/alpha/machdep.c | 6 +- sys/arch/amd64/amd64/db_memrw.c | 4 +- sys/arch/amd64/amd64/kgdb_machdep.c | 107 ------ sys/arch/amd64/amd64/machdep.c | 49 +-- sys/arch/amd64/amd64/trap.c | 29 +- sys/arch/amd64/conf/files.amd64 | 6 +- sys/arch/amd64/include/cpufunc.h | 4 +- sys/arch/amd64/include/db_machdep.h | 11 +- sys/arch/arm/arm/fault.c | 12 +- sys/arch/arm/arm/undefined.c | 5 +- sys/arch/arm/conf/files.arm | 5 +- sys/arch/arm64/dev/pluart.c | 3 +- sys/arch/arm64/include/machine_reg.h | 4 +- sys/arch/armv7/dev/pluart.c | 3 +- sys/arch/armv7/exynos/exuart.c | 3 +- sys/arch/armv7/imx/imxuart.c | 3 +- sys/arch/armv7/include/machine_reg.h | 4 +- sys/arch/i386/conf/files.i386 | 5 +- sys/arch/i386/i386/db_memrw.c | 4 +- sys/arch/i386/i386/kgdb_machdep.c | 204 ---------- sys/arch/i386/i386/machdep.c | 50 +-- sys/arch/i386/i386/trap.c | 33 +- sys/arch/i386/include/cpufunc.h | 4 +- sys/arch/i386/include/db_machdep.h | 11 +- sys/arch/sgi/hpc/zs.c | 12 +- sys/arch/sparc64/dev/cons.h | 7 +- sys/arch/sparc64/dev/zs.c | 6 +- sys/conf/files | 7 +- sys/ddb/db_run.c | 5 +- sys/dev/ic/com.c | 157 +------- sys/dev/ic/comvar.h | 12 +- sys/dev/ic/z8530sc.h | 4 +- sys/dev/ic/z8530tty.c | 17 +- sys/dev/isa/com_commulti.c | 6 +- sys/dev/isa/com_isa.c | 30 +- sys/dev/isa/com_isapnp.c | 18 +- sys/kern/kgdb_stub.c | 540 --------------------------- sys/kern/subr_prf.c | 8 +- sys/sys/kgdb.h | 110 ------ sys/sys/systm.h | 4 +- sys/uvm/uvm_extern.h | 5 +- sys/uvm/uvm_glue.c | 39 +- 44 files changed, 70 insertions(+), 1516 deletions(-) delete mode 100644 sys/arch/amd64/amd64/kgdb_machdep.c delete mode 100644 sys/arch/i386/i386/kgdb_machdep.c delete mode 100644 sys/kern/kgdb_stub.c delete mode 100644 sys/sys/kgdb.h diff --git a/sys/arch/alpha/alpha/dec_1000a.c b/sys/arch/alpha/alpha/dec_1000a.c index 0e2f5d76930..4e5e9b0e82d 100644 --- a/sys/arch/alpha/alpha/dec_1000a.c +++ b/sys/arch/alpha/alpha/dec_1000a.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dec_1000a.c,v 1.8 2014/05/08 20:46:49 miod Exp $ */ +/* $OpenBSD: dec_1000a.c,v 1.9 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: dec_1000a.c,v 1.14 2001/06/05 04:53:11 thorpej Exp $ */ /* @@ -103,15 +103,6 @@ void _dec_1000a_init(void); void dec_1000a_cons_init(void); void dec_1000a_device_register(struct device *, void *); -#ifdef KGDB -#include - -const char *kgdb_devlist[] = { - "com", - NULL, -}; -#endif /* KGDB */ - const struct alpha_variation_table dec_1000_variations[] = { { 0, "AlphaServer 1000" }, { 0, NULL }, @@ -233,10 +224,6 @@ dec_1000a_cons_init() panic("consinit: unknown console type %lu", (unsigned long)ctb->ctb_term_type); } -#ifdef KGDB - /* Attach the KGDB device. */ - alpha_kgdb_init(kgdb_devlist, iot); -#endif /* KGDB */ } void diff --git a/sys/arch/alpha/alpha/dec_kn300.c b/sys/arch/alpha/alpha/dec_kn300.c index fcce293235d..4ebbb5fa034 100644 --- a/sys/arch/alpha/alpha/dec_kn300.c +++ b/sys/arch/alpha/alpha/dec_kn300.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dec_kn300.c,v 1.8 2014/05/08 20:46:49 miod Exp $ */ +/* $OpenBSD: dec_kn300.c,v 1.9 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: dec_kn300.c,v 1.34 2007/03/04 15:18:10 yamt Exp $ */ /* @@ -80,15 +80,6 @@ void dec_kn300_init (void); void dec_kn300_cons_init (void); static void dec_kn300_device_register (struct device *, void *); -#ifdef KGDB -#include - -static const char *kgdb_devlist[] = { - "com", - NULL, -}; -#endif /* KGDB */ - #define ALPHASERVER_4100 "AlphaServer 4100" const struct alpha_variation_table dec_kn300_variations[] = { @@ -202,10 +193,6 @@ dec_kn300_cons_init() panic("consinit: unknown console type %lu", (unsigned long)ctb->ctb_term_type); } -#ifdef KGDB - /* Attach the KGDB device. */ - alpha_kgdb_init(kgdb_devlist, &ccp->cc_iot); -#endif /* KGDB */ } static void diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index 56ee777d1b2..8a22b6bcb71 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.178 2017/04/27 11:48:08 mpi Exp $ */ +/* $OpenBSD: machdep.c,v 1.179 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */ /*- @@ -763,10 +763,6 @@ nobootinfo: if (boothowto & RB_KDB) Debugger(); -#endif -#ifdef KGDB - if (boothowto & RB_KDB) - kgdb_connect(0); #endif /* * Figure out our clock frequency, from RPB fields. diff --git a/sys/arch/amd64/amd64/db_memrw.c b/sys/arch/amd64/amd64/db_memrw.c index 7c4a6540a05..8d75cc3baf4 100644 --- a/sys/arch/amd64/amd64/db_memrw.c +++ b/sys/arch/amd64/amd64/db_memrw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_memrw.c,v 1.7 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: db_memrw.c,v 1.8 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: db_memrw.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /*- @@ -32,8 +32,6 @@ /* * Interface to the debugger for virtual memory read/write. - * This file is shared by DDB and KGDB, and must work even - * when only KGDB is included (thus no db_printf calls). * * To write in the text segment, we have to first make * the page writable, do the write, then restore the PTE. diff --git a/sys/arch/amd64/amd64/kgdb_machdep.c b/sys/arch/amd64/amd64/kgdb_machdep.c deleted file mode 100644 index b510b1890f4..00000000000 --- a/sys/arch/amd64/amd64/kgdb_machdep.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $OpenBSD: kgdb_machdep.c,v 1.1 2005/11/13 17:51:52 fgsch Exp $ */ -/* - * Copyright (c) 2005 Federico G. Schwindt - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS - * ``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 OPENBSD - * PROJECT OR CONTRIBUTORS 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. - */ - -#include - -int -kgdb_acc(vaddr_t va, size_t len) -{ - vaddr_t last_va; - pt_entry_t *pte; - - last_va = va + len; - va &= ~PGOFSET; - last_va &= PGOFSET; - - do { - pte = kvtopte(va); - if ((*pte & PG_V) == 0) - return (0); - va += NBPG; - } while (va < last_va); - - return (1); -} - -int -kgdb_signal(int type) -{ - switch (type) { - default: - return (SIGEMT); - } -} - -void -kgdb_getregs(db_regs_t *regs, kgdb_reg_t *gdb_regs) -{ - gdb_regs[ 0] = regs->tf_rax; - gdb_regs[ 1] = regs->tf_rbx; - gdb_regs[ 2] = regs->tf_rcx; - gdb_regs[ 3] = regs->tf_rdx; - gdb_regs[ 4] = regs->tf_rsi; - gdb_regs[ 5] = regs->tf_rdi; - gdb_regs[ 6] = regs->tf_rbp; - gdb_regs[ 7] = regs->tf_rsp; - gdb_regs[ 8] = regs->tf_r8; - gdb_regs[ 9] = regs->tf_r9; - gdb_regs[10] = regs->tf_r10; - gdb_regs[11] = regs->tf_r11; - gdb_regs[12] = regs->tf_r12; - gdb_regs[13] = regs->tf_r13; - gdb_regs[14] = regs->tf_r14; - gdb_regs[15] = regs->tf_r15; - gdb_regs[16] = regs->tf_rip; - /* XXX: 32bits but defined as 64 */ - gdb_regs[17] = regs->tf_rflags; - gdb_regs[18] = regs->tf_cs; - gdb_regs[19] = regs->tf_ss; -} - -void -kgdb_setregs(db_regs_t *regs, kgdb_reg_t *gdb_regs) -{ - regs->tf_rax = gdb_regs[ 0]; - regs->tf_rbx = gdb_regs[ 1]; - regs->tf_rcx = gdb_regs[ 2]; - regs->tf_rdx = gdb_regs[ 3]; - regs->tf_rsi = gdb_regs[ 4]; - regs->tf_rdi = gdb_regs[ 5]; - regs->tf_rbp = gdb_regs[ 6]; - regs->tf_rsp = gdb_regs[ 7]; - regs->tf_r8 = gdb_regs[ 8]; - regs->tf_r9 = gdb_regs[ 9]; - regs->tf_r10 = gdb_regs[10]; - regs->tf_r11 = gdb_regs[11]; - regs->tf_r12 = gdb_regs[12]; - regs->tf_r13 = gdb_regs[13]; - regs->tf_r14 = gdb_regs[14]; - regs->tf_r15 = gdb_regs[15]; - regs->tf_rip = gdb_regs[16]; - regs->tf_rflags = gdb_regs[17]; - regs->tf_cs = gdb_regs[18]; - regs->tf_ss = gdb_regs[19]; -} diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 09b16d93546..e8289c206f4 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.226 2017/03/11 11:55:03 mpi Exp $ */ +/* $OpenBSD: machdep.c,v 1.227 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -87,10 +87,6 @@ #include #include -#ifdef KGDB -#include -#endif - #include #include @@ -268,28 +264,6 @@ void map_tramps(void); void init_x86_64(paddr_t); void (*cpuresetfn)(void); -#ifdef KGDB -#ifndef KGDB_DEVNAME -#define KGDB_DEVNAME "com" -#endif /* KGDB_DEVNAME */ -char kgdb_devname[] = KGDB_DEVNAME; -#if NCOM > 0 -#ifndef KGDBADDR -#define KGDBADDR 0x3f8 -#endif /* KGDBADDR */ -int comkgdbaddr = KGDBADDR; -#ifndef KGDBRATE -#define KGDBRATE TTYDEF_SPEED -#endif /* KGDBRATE */ -int comkgdbrate = KGDBRATE; -#ifndef KGDBMODE -#define KGDBMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) -#endif /* KGDBMODE */ -int comkgdbmode = KGDBMODE; -#endif /* NCOM */ -void kgdb_port_init(void); -#endif /* KGDB */ - #ifdef APERTURE int allowaperture = 0; #endif @@ -1630,29 +1604,8 @@ init_x86_64(paddr_t first_avail) if (boothowto & RB_KDB) Debugger(); #endif -#ifdef KGDB - kgdb_port_init(); - if (boothowto & RB_KDB) { - kgdb_debug_init = 1; - kgdb_connect(1); - } -#endif } -#ifdef KGDB -void -kgdb_port_init(void) -{ -#if NCOM > 0 - if (!strcmp(kgdb_devname, "com")) { - bus_space_tag_t tag = X86_BUS_SPACE_IO; - com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ, - comkgdbmode); - } -#endif -} -#endif /* KGDB */ - void cpu_reset(void) { diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 771a1e8ae14..d57493248ab 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.53 2017/03/03 20:49:47 bluhm Exp $ */ +/* $OpenBSD: trap.c,v 1.54 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -93,10 +93,6 @@ #include "isa.h" -#ifdef KGDB -#include -#endif - void trap(struct trapframe *); void ast(struct trapframe *); void syscall(struct trapframe *); @@ -180,20 +176,6 @@ trap(struct trapframe *frame) default: we_re_toast: -#ifdef KGDB - if (kgdb_trap(type, frame)) - return; - else { - /* - * If this is a breakpoint, don't panic - * if we're not connected. - */ - if (type == T_BPTFLT) { - printf("kgdb: ignored %s\n", trap_type[type]); - return; - } - } -#endif #ifdef DDB if (db_ktrap(type, 0, frame)) return; @@ -427,19 +409,12 @@ faultcommon: #if NISA > 0 case T_NMI: case T_NMI|T_USER: -#if defined(KGDB) || defined(DDB) +#ifdef DDB /* NMI can be hooked up to a pushbutton for debugging */ printf ("NMI ... going to debugger\n"); -#ifdef KGDB - - if (kgdb_trap(type, frame)) - return; -#endif -#ifdef DDB if (db_ktrap(type, 0, frame)) return; #endif -#endif /* KGDB || DDB */ /* machine/parity/power fail/"kitchen sink" faults */ if (x86_nmi() != 0) diff --git a/sys/arch/amd64/conf/files.amd64 b/sys/arch/amd64/conf/files.amd64 index ab744edcbde..2700c7c7158 100644 --- a/sys/arch/amd64/conf/files.amd64 +++ b/sys/arch/amd64/conf/files.amd64 @@ -1,4 +1,4 @@ -# $OpenBSD: files.amd64,v 1.87 2017/01/21 10:58:15 reyk Exp $ +# $OpenBSD: files.amd64,v 1.88 2017/04/30 13:04:49 mpi Exp $ maxpartitions 16 maxusers 2 16 128 @@ -50,14 +50,12 @@ file arch/amd64/amd64/dkcsum.c bios file arch/amd64/amd64/db_disasm.c ddb file arch/amd64/amd64/db_interface.c ddb -file arch/amd64/amd64/db_memrw.c ddb | kgdb +file arch/amd64/amd64/db_memrw.c ddb file arch/amd64/amd64/db_trace.c ddb file netinet/in_cksum.c file netinet/in4_cksum.c -file arch/amd64/amd64/kgdb_machdep.c kgdb - # Basic clock - required file arch/amd64/isa/clock.c diff --git a/sys/arch/amd64/include/cpufunc.h b/sys/arch/amd64/include/cpufunc.h index bda18a00287..0063241a4f9 100644 --- a/sys/arch/amd64/include/cpufunc.h +++ b/sys/arch/amd64/include/cpufunc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpufunc.h,v 1.14 2017/04/27 06:16:39 mlarkin Exp $ */ +/* $OpenBSD: cpufunc.h,v 1.15 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: cpufunc.h,v 1.3 2003/05/08 10:27:43 fvdl Exp $ */ /*- @@ -345,7 +345,7 @@ xgetbv(uint32_t reg) return (((uint64_t)hi << 32) | (uint64_t)lo); } -/* Break into DDB/KGDB. */ +/* Break into DDB. */ static __inline void breakpoint(void) { diff --git a/sys/arch/amd64/include/db_machdep.h b/sys/arch/amd64/include/db_machdep.h index 6d554ebc9e3..643b1d43780 100644 --- a/sys/arch/amd64/include/db_machdep.h +++ b/sys/arch/amd64/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.h,v 1.15 2016/09/04 09:22:28 mpi Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.16 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: db_machdep.h,v 1.2 2003/04/29 17:06:04 scw Exp $ */ /* @@ -76,15 +76,6 @@ extern db_regs_t ddb_regs; /* register state */ (((ins)&0xff) == I_CALLI && \ ((ins)&0x3800) == 0x1000)) -/* - * Constants for KGDB. - */ -typedef long kgdb_reg_t; -#define KGDB_NUMREGS 20 -#define KGDB_BUFLEN 512 - -#define KGDB_ENTER breakpoint() - /* macro for checking if a thread has used floating-point */ int db_ktrap(int, int, db_regs_t *); diff --git a/sys/arch/arm/arm/fault.c b/sys/arch/arm/arm/fault.c index 9ff47c590ba..7ed4ce466b3 100644 --- a/sys/arch/arm/arm/fault.c +++ b/sys/arch/arm/arm/fault.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fault.c,v 1.27 2017/01/21 05:42:03 guenther Exp $ */ +/* $OpenBSD: fault.c,v 1.28 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: fault.c,v 1.46 2004/01/21 15:39:21 skrll Exp $ */ /* @@ -94,14 +94,8 @@ #include #include #include -#if defined(DDB) || defined(KGDB) +#ifdef DDB #include -#ifdef KGDB -#include -#endif -#if !defined(DDB) -#define db_ktrap kgdb_trap -#endif #endif #include @@ -417,7 +411,7 @@ dab_fatal(trapframe_t *tf, u_int fsr, u_int far, struct proc *p, tf->tf_svc_sp, tf->tf_svc_lr); printf(", pc =%08lx\n\n", tf->tf_pc); -#if defined(DDB) || defined(KGDB) +#ifdef DDB db_ktrap(T_FAULT, tf); #endif panic("Fatal abort"); diff --git a/sys/arch/arm/arm/undefined.c b/sys/arch/arm/arm/undefined.c index 4fb64cbff99..95a9d451b4c 100644 --- a/sys/arch/arm/arm/undefined.c +++ b/sys/arch/arm/arm/undefined.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undefined.c,v 1.8 2016/06/10 06:32:36 jsg Exp $ */ +/* $OpenBSD: undefined.c,v 1.9 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: undefined.c,v 1.22 2003/11/29 22:21:29 bjh21 Exp $ */ /* @@ -115,9 +115,6 @@ gdb_trapper(u_int addr, u_int insn, struct trapframe *frame, int code) trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv); return 0; } -#ifdef KGDB - return !kgdb_trap(T_BREAKPOINT, frame); -#endif } return 1; } diff --git a/sys/arch/arm/conf/files.arm b/sys/arch/arm/conf/files.arm index 671bc3fbed6..9dae5a17689 100644 --- a/sys/arch/arm/conf/files.arm +++ b/sys/arch/arm/conf/files.arm @@ -1,4 +1,4 @@ -# $OpenBSD: files.arm,v 1.45 2017/04/27 22:41:46 kettenis Exp $ +# $OpenBSD: files.arm,v 1.46 2017/04/30 13:04:49 mpi Exp $ # $NetBSD: files.arm,v 1.76 2003/11/05 12:53:15 scw Exp $ # generic networking files @@ -6,10 +6,9 @@ file arch/arm/arm/in_cksum_arm.S # DDB file arch/arm/arm/db_disasm.c ddb -file arch/arm/arm/db_interface.c (ddb|kgdb) +file arch/arm/arm/db_interface.c ddb file arch/arm/arm/db_trace.c ddb file arch/arm/arm/db_machdep.c ddb -file arch/arm/arm/kgdb_machdep.c kgdb file arch/arm/arm/disassem.c ddb # FIQ support diff --git a/sys/arch/arm64/dev/pluart.c b/sys/arch/arm64/dev/pluart.c index 3d468709044..f61b4e61ce2 100644 --- a/sys/arch/arm64/dev/pluart.c +++ b/sys/arch/arm64/dev/pluart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pluart.c,v 1.3 2017/04/11 15:16:14 kettenis Exp $ */ +/* $OpenBSD: pluart.c,v 1.4 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 2014 Patrick Wildt @@ -145,7 +145,6 @@ struct pluart_softc { #define COM_HW_FIFO 0x02 #define COM_HW_SIR 0x20 #define COM_HW_CONSOLE 0x40 -#define COM_HW_KGDB 0x80 u_int8_t sc_swflags; #define COM_SW_SOFTCAR 0x01 #define COM_SW_CLOCAL 0x02 diff --git a/sys/arch/arm64/include/machine_reg.h b/sys/arch/arm64/include/machine_reg.h index 033d6603cdc..114a7529a2a 100644 --- a/sys/arch/arm64/include/machine_reg.h +++ b/sys/arch/arm64/include/machine_reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: machine_reg.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: machine_reg.h,v 1.2 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved. @@ -43,7 +43,7 @@ #define MACHINE_AGPIO_VBASE 0xfd300000 #define MACHINE_VBASE_FREE 0xfd400000 /* FFUART and/or BTUART are mapped to this area when - used for console or kgdb port */ + used for console */ #define ioreg_read(a) (*(volatile unsigned *)(a)) #define ioreg_write(a,v) (*(volatile unsigned *)(a)=(v)) diff --git a/sys/arch/armv7/dev/pluart.c b/sys/arch/armv7/dev/pluart.c index 5374438c2c6..af078552f2f 100644 --- a/sys/arch/armv7/dev/pluart.c +++ b/sys/arch/armv7/dev/pluart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pluart.c,v 1.2 2017/04/11 15:16:14 kettenis Exp $ */ +/* $OpenBSD: pluart.c,v 1.3 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 2014 Patrick Wildt @@ -146,7 +146,6 @@ struct pluart_softc { #define COM_HW_FIFO 0x02 #define COM_HW_SIR 0x20 #define COM_HW_CONSOLE 0x40 -#define COM_HW_KGDB 0x80 u_int8_t sc_swflags; #define COM_SW_SOFTCAR 0x01 #define COM_SW_CLOCAL 0x02 diff --git a/sys/arch/armv7/exynos/exuart.c b/sys/arch/armv7/exynos/exuart.c index fc66293a774..aaea9a7cca3 100644 --- a/sys/arch/armv7/exynos/exuart.c +++ b/sys/arch/armv7/exynos/exuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exuart.c,v 1.10 2017/03/07 20:14:20 kettenis Exp $ */ +/* $OpenBSD: exuart.c,v 1.11 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 2005 Dale Rahn * @@ -74,7 +74,6 @@ struct exuart_softc { #define COM_HW_FIFO 0x02 #define COM_HW_SIR 0x20 #define COM_HW_CONSOLE 0x40 -#define COM_HW_KGDB 0x80 u_int8_t sc_swflags; #define COM_SW_SOFTCAR 0x01 #define COM_SW_CLOCAL 0x02 diff --git a/sys/arch/armv7/imx/imxuart.c b/sys/arch/armv7/imx/imxuart.c index e4e0b1d2cae..1b460568b06 100644 --- a/sys/arch/armv7/imx/imxuart.c +++ b/sys/arch/armv7/imx/imxuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxuart.c,v 1.13 2016/12/28 22:45:24 kettenis Exp $ */ +/* $OpenBSD: imxuart.c,v 1.14 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 2005 Dale Rahn * @@ -74,7 +74,6 @@ struct imxuart_softc { #define COM_HW_FIFO 0x02 #define COM_HW_SIR 0x20 #define COM_HW_CONSOLE 0x40 -#define COM_HW_KGDB 0x80 u_int8_t sc_swflags; #define COM_SW_SOFTCAR 0x01 #define COM_SW_CLOCAL 0x02 diff --git a/sys/arch/armv7/include/machine_reg.h b/sys/arch/armv7/include/machine_reg.h index 5b0fd83d8b9..645c045091b 100644 --- a/sys/arch/armv7/include/machine_reg.h +++ b/sys/arch/armv7/include/machine_reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: machine_reg.h,v 1.1 2013/09/04 14:38:28 patrick Exp $ */ +/* $OpenBSD: machine_reg.h,v 1.2 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved. @@ -43,7 +43,7 @@ #define MACHINE_AGPIO_VBASE 0xfd300000 #define MACHINE_VBASE_FREE 0xfd400000 /* FFUART and/or BTUART are mapped to this area when - used for console or kgdb port */ + used for console */ #define ioreg_read(a) (*(volatile unsigned *)(a)) #define ioreg_write(a,v) (*(volatile unsigned *)(a)=(v)) diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index a170dd10547..2ca9e1264fd 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: files.i386,v 1.231 2017/01/21 10:58:15 reyk Exp $ +# $OpenBSD: files.i386,v 1.232 2017/04/30 13:04:49 mpi Exp $ # # new style config file for i386 architecture # @@ -14,7 +14,7 @@ file arch/i386/i386/bus_dma.c file arch/i386/i386/conf.c file arch/i386/i386/db_disasm.c ddb file arch/i386/i386/db_interface.c ddb -file arch/i386/i386/db_memrw.c ddb | kgdb +file arch/i386/i386/db_memrw.c ddb file arch/i386/i386/db_trace.c ddb file arch/i386/i386/disksubr.c disk file arch/i386/i386/est.c !small_kernel @@ -24,7 +24,6 @@ file arch/i386/i386/machdep.c file arch/i386/i386/hibernate_machdep.c hibernate file arch/i386/i386/via.c file arch/i386/i386/amd64errata.c !small_kernel -file arch/i386/i386/kgdb_machdep.c kgdb file arch/i386/i386/longrun.c !small_kernel file arch/i386/i386/mem.c file arch/i386/i386/i686_mem.c mtrr diff --git a/sys/arch/i386/i386/db_memrw.c b/sys/arch/i386/i386/db_memrw.c index cc28763301f..39b72c99a3d 100644 --- a/sys/arch/i386/i386/db_memrw.c +++ b/sys/arch/i386/i386/db_memrw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_memrw.c,v 1.16 2015/12/18 08:15:09 gerhard Exp $ */ +/* $OpenBSD: db_memrw.c,v 1.17 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: db_memrw.c,v 1.6 1999/04/12 20:38:19 pk Exp $ */ /* @@ -31,7 +31,7 @@ /* * Routines to read and write memory on behalf of the debugger, used - * by DDB and KGDB. + * by DDB. */ #include diff --git a/sys/arch/i386/i386/kgdb_machdep.c b/sys/arch/i386/i386/kgdb_machdep.c deleted file mode 100644 index 1a46515fd7c..00000000000 --- a/sys/arch/i386/i386/kgdb_machdep.c +++ /dev/null @@ -1,204 +0,0 @@ -/* $OpenBSD: kgdb_machdep.c,v 1.13 2015/06/28 01:11:27 guenther Exp $ */ -/* $NetBSD: kgdb_machdep.c,v 1.6 1998/08/13 21:36:03 thorpej Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``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 FOUNDATION OR CONTRIBUTORS - * 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. - */ - -/* - * Copyright (c) 1996 Matthias Pfaller. - * All rights reserved. - * - * 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. - * - * 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. - */ - -#if defined(DDB) -#error "Can't build DDB and KGDB together." -#endif - -/* - * Machine-dependent functions for remote KGDB. Originally written - * for NetBSD/pc532 by Matthias Pfaller. Modified for NetBSD/i386 - * by Jason R. Thorpe. - */ - -#include -#include -#include - -#include - -#include -#include -#include - -/* - * Determine if the memory at va..(va+len) is valid. - */ -int -kgdb_acc(vaddr_t va, size_t len) -{ - vaddr_t last_va; - - last_va = va + len; - va &= ~PGOFSET; - last_va &= ~PGOFSET; - - do { - if ((pmap_pte_bits(va) & PG_V) == 0) - return (0); - va += NBPG; - } while (va < last_va); - - return (1); -} - -/* - * Translate a trap number into a unix compatible signal value. - * (gdb only understands unix signal numbers). - */ -int -kgdb_signal(int type) -{ - switch (type) { - case T_NMI: - return (SIGINT); - - case T_ALIGNFLT: - return (SIGILL); - - case T_BPTFLT: - case T_TRCTRAP: - return (SIGTRAP); - - case T_DOUBLEFLT: - return (SIGEMT); - - case T_ARITHTRAP: - case T_DIVIDE: - case T_OFLOW: - case T_DNA: - case T_FPOPFLT: - return (SIGFPE); - - case T_PRIVINFLT: - case T_PROTFLT: - case T_PAGEFLT: - case T_TSSFLT: - case T_SEGNPFLT: - case T_STKFLT: - return (SIGSEGV); - - case T_BOUND: - return (SIGURG); - - default: - return (SIGEMT); - } -} - -/* - * Translate the values stored in the kernel regs struct to the format - * understood by gdb. - */ -void -kgdb_getregs(db_regs_t *regs, kgdb_reg_t *gdb_regs) -{ - - gdb_regs[ 0] = regs->tf_eax; - gdb_regs[ 1] = regs->tf_ecx; - gdb_regs[ 2] = regs->tf_edx; - gdb_regs[ 3] = regs->tf_ebx; - gdb_regs[ 5] = regs->tf_ebp; - gdb_regs[ 6] = regs->tf_esi; - gdb_regs[ 7] = regs->tf_edi; - gdb_regs[ 8] = regs->tf_eip; - gdb_regs[ 9] = regs->tf_eflags; - gdb_regs[10] = regs->tf_cs; - gdb_regs[12] = regs->tf_ds; - gdb_regs[13] = regs->tf_es; - gdb_regs[14] = regs->tf_fs; - gdb_regs[15] = regs->tf_gs; - - if (KERNELMODE(regs->tf_cs, regs->tf_eflags)) { - /* - * Kernel mode - esp and ss not saved. - */ - gdb_regs[ 4] = (kgdb_reg_t)®s->tf_esp; /* kernel stack - pointer */ - __asm volatile("movw %%ss,%w0" : "=r" (gdb_regs[11])); - } -} - -/* - * Reverse the above. - */ -void -kgdb_setregs(db_regs_t *regs, kgdb_reg_t *gdb_regs) -{ - - regs->tf_eax = gdb_regs[ 0]; - regs->tf_ecx = gdb_regs[ 1]; - regs->tf_edx = gdb_regs[ 2]; - regs->tf_ebx = gdb_regs[ 3]; - regs->tf_ebp = gdb_regs[ 5]; - regs->tf_esi = gdb_regs[ 6]; - regs->tf_edi = gdb_regs[ 7]; - regs->tf_eip = gdb_regs[ 8]; - regs->tf_eflags = gdb_regs[ 9]; - regs->tf_cs = gdb_regs[10]; - regs->tf_ds = gdb_regs[12]; - regs->tf_es = gdb_regs[13]; - - if (KERNELMODE(regs->tf_cs, regs->tf_eflags) == 0) { - /* - * Trapped in user mode - restore esp and ss. - */ - regs->tf_esp = gdb_regs[ 4]; - regs->tf_ss = gdb_regs[11]; - } -} diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 5c0fa2f6dd1..b66741c801e 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.598 2017/03/11 11:55:03 mpi Exp $ */ +/* $OpenBSD: machdep.c,v 1.599 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -92,10 +92,6 @@ #include #include -#ifdef KGDB -#include -#endif - #include #include @@ -287,28 +283,6 @@ void (*cpuresetfn)(void); int bus_mem_add_mapping(bus_addr_t, bus_size_t, int, bus_space_handle_t *); -#ifdef KGDB -#ifndef KGDB_DEVNAME -#define KGDB_DEVNAME "com" -#endif /* KGDB_DEVNAME */ -char kgdb_devname[] = KGDB_DEVNAME; -#if NCOM > 0 -#ifndef KGDBADDR -#define KGDBADDR 0x3f8 -#endif -int comkgdbaddr = KGDBADDR; -#ifndef KGDBRATE -#define KGDBRATE TTYDEF_SPEED -#endif -int comkgdbrate = KGDBRATE; -#ifndef KGDBMODE -#define KGDBMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ -#endif -int comkgdbmode = KGDBMODE; -#endif /* NCOM > 0 */ -void kgdb_port_init(void); -#endif /* KGDB */ - #ifdef APERTURE int allowaperture = 0; #endif @@ -3405,13 +3379,6 @@ init386(paddr_t first_avail) if (boothowto & RB_KDB) Debugger(); #endif -#ifdef KGDB - kgdb_port_init(); - if (boothowto & RB_KDB) { - kgdb_debug_init = 1; - kgdb_connect(1); - } -#endif /* KGDB */ softintr_init(); } @@ -3426,21 +3393,6 @@ consinit(void) /* Already done in init386(). */ } -#ifdef KGDB -void -kgdb_port_init(void) -{ - -#if NCOM > 0 - if (!strcmp(kgdb_devname, "com")) { - bus_space_tag_t tag = I386_BUS_SPACE_IO; - com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ, - comkgdbmode); - } -#endif -} -#endif /* KGDB */ - void cpu_reset(void) { diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index c2a036b9425..018c17afd11 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.129 2017/04/08 03:29:13 mlarkin Exp $ */ +/* $OpenBSD: trap.c,v 1.130 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -62,10 +62,6 @@ #include #endif -#ifdef KGDB -#include -#endif - #include #ifdef KVM86 #include @@ -159,28 +155,13 @@ trap(struct trapframe *frame) /* trace trap */ case T_TRCTRAP: -#if !(defined(DDB) || defined(KGDB)) +#ifndef DDB return; /* Just return if no kernel debugger */ #endif /* FALLTHROUGH */ default: we_re_toast: -#ifdef KGDB - if (kgdb_trap(type, frame)) - return; - else { - /* - * If this is a breakpoint, don't panic - * if we're not connected. - */ - if (type == T_BPTFLT) { - printf("kgdb: ignored %s\n", trap_type[type]); - return; - } - } -#endif - #ifdef DDB if (db_ktrap(type, 0, frame)) return; @@ -457,7 +438,7 @@ trap(struct trapframe *frame) } #if 0 /* Should this be left out? */ -#if !defined(DDB) && !defined(KGDB) +#if !defined(DDB) /* XXX need to deal with this when DDB is present, too */ case T_TRCTRAP: /* kernel trace trap; someone single stepping lcall's */ /* syscall has to turn off the trace bit itself */ @@ -481,18 +462,12 @@ trap(struct trapframe *frame) #if NISA > 0 case T_NMI: case T_NMI|T_USER: -#if defined(DDB) || defined(KGDB) +#ifdef DDB /* NMI can be hooked up to a pushbutton for debugging */ printf ("NMI ... going to debugger\n"); -#ifdef KGDB - if (kgdb_trap(type, frame)) - return; -#endif -#ifdef DDB if (db_ktrap(type, 0, frame)) return; #endif -#endif /* DDB || KGDB */ /* machine/parity/power fail/"kitchen sink" faults */ if (isa_nmi() == 0) return; diff --git a/sys/arch/i386/include/cpufunc.h b/sys/arch/i386/include/cpufunc.h index 2262237c229..3bcd61ab84f 100644 --- a/sys/arch/i386/include/cpufunc.h +++ b/sys/arch/i386/include/cpufunc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpufunc.h,v 1.23 2017/02/06 09:13:41 mpi Exp $ */ +/* $OpenBSD: cpufunc.h,v 1.24 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: cpufunc.h,v 1.8 1994/10/27 04:15:59 cgd Exp $ */ /* @@ -303,7 +303,7 @@ wrmsr_locked(u_int msr, u_int code, u_int64_t newval) : "A" (newval), "c" (msr), "D" (code)); } -/* Break into DDB/KGDB. */ +/* Break into DDB. */ static __inline void breakpoint(void) { diff --git a/sys/arch/i386/include/db_machdep.h b/sys/arch/i386/include/db_machdep.h index 5d9fb9bd5e8..2654c691e23 100644 --- a/sys/arch/i386/include/db_machdep.h +++ b/sys/arch/i386/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.h,v 1.26 2017/02/06 09:13:41 mpi Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.27 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: db_machdep.h,v 1.9 1996/05/03 19:23:59 christos Exp $ */ /* @@ -75,15 +75,6 @@ extern db_regs_t ddb_regs; /* register state */ #define DB_MACHINE_COMMANDS -/* - * Constants for KGDB. - */ -typedef long kgdb_reg_t; -#define KGDB_NUMREGS 16 -#define KGDB_BUFLEN 512 - -#define KGDB_ENTER breakpoint() - /* macro for checking if a thread has used floating-point */ int db_ktrap(int, int, db_regs_t *); diff --git a/sys/arch/sgi/hpc/zs.c b/sys/arch/sgi/hpc/zs.c index 1f452b0a70a..cc52bb13a0f 100644 --- a/sys/arch/sgi/hpc/zs.c +++ b/sys/arch/sgi/hpc/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.13 2014/12/07 13:12:05 miod Exp $ */ +/* $OpenBSD: zs.c,v 1.14 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: zs.c,v 1.37 2011/02/20 07:59:50 matt Exp $ */ /*- @@ -558,17 +558,15 @@ zs_write_data(struct zs_chanstate *cs, uint8_t val) void zs_abort(struct zs_chanstate *cs) { -#if defined(KGDB) - zskgdb(cs); -#elif defined(DDB) +#if defined(DDB) Debugger(); #endif } -/*********************************************************/ -/* Polled character I/O functions for console and KGDB */ -/*********************************************************/ +/*****************************************************/ +/* Polled character I/O functions for console KGDB */ +/*****************************************************/ struct zschan * zs_get_chan_addr(int zs_unit, int channel) diff --git a/sys/arch/sparc64/dev/cons.h b/sys/arch/sparc64/dev/cons.h index 0419815fbe7..71a1b9d382c 100644 --- a/sys/arch/sparc64/dev/cons.h +++ b/sys/arch/sparc64/dev/cons.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cons.h,v 1.3 2007/03/07 06:23:04 miod Exp $ */ +/* $OpenBSD: cons.h,v 1.4 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: cons.h,v 1.3 2000/05/19 05:26:17 eeh Exp $ */ /*- @@ -45,8 +45,3 @@ extern void zs_putc(void *arg, int c); struct zschan * zs_get_chan_addr(int zsc_unit, int channel); - -#ifdef KGDB -void zs_kgdb_init(void); -void zskgdb(struct zs_chanstate *); -#endif diff --git a/sys/arch/sparc64/dev/zs.c b/sys/arch/sparc64/dev/zs.c index 3e6c99b6fa6..5c2668a09b8 100644 --- a/sys/arch/sparc64/dev/zs.c +++ b/sys/arch/sparc64/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.27 2015/02/05 12:04:58 miod Exp $ */ +/* $OpenBSD: zs.c,v 1.28 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: zs.c,v 1.29 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -689,9 +689,7 @@ zs_abort(cs) ZS_DELAY(); } while (rr0 & ZSRR0_BREAK); -#if defined(KGDB) - zskgdb(cs); -#elif defined(DDB) +#if defined(DDB) { extern int db_active; diff --git a/sys/conf/files b/sys/conf/files index e9d35078631..d67329da211 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.642 2017/04/28 13:50:54 mpi Exp $ +# $OpenBSD: files,v 1.643 2017/04/30 13:04:49 mpi Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -594,7 +594,7 @@ file net/if_pppoe.c pppoe needs-flag # XXX machine-independent SCSI files should live somewhere here, maybe # kernel sources -file ddb/db_access.c ddb | kgdb +file ddb/db_access.c ddb file ddb/db_break.c ddb file ddb/db_command.c ddb file ddb/db_ctf.c ddb & ddbctf @@ -607,7 +607,7 @@ file ddb/db_input.c ddb file ddb/db_lex.c ddb file ddb/db_output.c ddb file ddb/db_prof.c ddb & ddbprof & !gprof -file ddb/db_run.c ddb | kgdb +file ddb/db_run.c ddb file ddb/db_struct.c ddb & ddb_struct file ddb/db_sym.c ddb file ddb/db_trap.c ddb @@ -683,7 +683,6 @@ file kern/kern_watchdog.c !small_kernel file kern/kern_task.c file kern/kern_srp.c file kern/kern_xxx.c -file kern/kgdb_stub.c kgdb file kern/sched_bsd.c file kern/subr_autoconf.c file kern/subr_disk.c diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c index f301c1cb40c..d33146b367c 100644 --- a/sys/ddb/db_run.c +++ b/sys/ddb/db_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_run.c,v 1.26 2016/01/25 14:30:30 mpi Exp $ */ +/* $OpenBSD: db_run.c,v 1.27 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: db_run.c,v 1.8 1996/02/05 01:57:12 christos Exp $ */ /* @@ -49,8 +49,6 @@ db_breakpoint_t db_taken_bkpt = 0; int db_inst_count; -#ifndef KGDB - #include #include #include @@ -295,7 +293,6 @@ db_continue_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) db_cmd_loop_done = 1; } -#endif /* NO KGDB */ #ifdef SOFTWARE_SSTEP /* diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 97598036e0e..6fa8fe9a925 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.161 2016/09/04 18:20:34 tedu Exp $ */ +/* $OpenBSD: com.c,v 1.162 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -115,17 +115,6 @@ tcflag_t comconscflag = TTYDEF_CFLAG; int commajor; -#ifdef KGDB -#include - -bus_addr_t com_kgdb_addr; -bus_space_tag_t com_kgdb_iot; -bus_space_handle_t com_kgdb_ioh; - -int com_kgdb_getc(void *); -void com_kgdb_putc(void *, int); -#endif /* KGDB */ - #define DEVUNIT(x) (minor(x) & 0x7f) #define DEVCUA(x) (minor(x) & 0x80) @@ -227,11 +216,7 @@ com_activate(struct device *self, int act) com_resume(sc); break; case DVACT_DEACTIVATE: -#ifdef KGDB - if (sc->sc_hwflags & (COM_HW_CONSOLE|COM_HW_KGDB)) { -#else if (sc->sc_hwflags & COM_HW_CONSOLE) { -#endif /* KGDB */ rv = EBUSY; break; } @@ -264,14 +249,6 @@ comopen(dev_t dev, int flag, int mode, struct proc *p) if (!sc) return ENXIO; -#ifdef KGDB - /* - * If this is the kgdb port, no other use is permitted. - */ - if (ISSET(sc->sc_hwflags, COM_HW_KGDB)) - return (EBUSY); -#endif /* KGDB */ - s = spltty(); if (!sc->sc_tty) { tp = sc->sc_tty = ttymalloc(1000000); @@ -1080,61 +1057,6 @@ comsoft(void *arg) } } -#ifdef KGDB - -/* - * If a line break is set, or data matches one of the characters - * gdb uses to signal a connection, then start up kgdb. Just gobble - * any other data. Done in a stand alone function because comintr - * does tty stuff and we don't have one. - */ - -int -kgdbintr(void *arg) -{ - struct com_softc *sc = arg; - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_char lsr, data, msr, delta; - - if (!ISSET(sc->sc_hwflags, COM_HW_KGDB)) - return(0); - - for (;;) { - lsr = bus_space_read_1(iot, ioh, com_lsr); - if (ISSET(lsr, LSR_RXRDY)) { - do { - data = bus_space_read_1(iot, ioh, com_data); - if (data == 3 || data == '$' || data == '+' || - ISSET(lsr, LSR_BI)) { - kgdb_connect(1); - data = 0; - } - lsr = bus_space_read_1(iot, ioh, com_lsr); - } while (ISSET(lsr, LSR_RXRDY)); - - } - if (ISSET(lsr, LSR_BI|LSR_FE|LSR_PE|LSR_OE)) - printf("weird lsr %02x\n", lsr); - - msr = bus_space_read_1(iot, ioh, com_msr); - - if (msr != sc->sc_msr) { - delta = msr ^ sc->sc_msr; - sc->sc_msr = msr; - if (ISSET(delta, MSR_DCD)) { - if (!ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) { - CLR(sc->sc_mcr, sc->sc_dtr); - bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); - } - } - } - if (ISSET(bus_space_read_1(iot, ioh, com_iir), IIR_NOPEND)) - return (1); - } -} -#endif /* KGDB */ - int comintr(void *arg) { @@ -1231,8 +1153,8 @@ comintr(void *arg) } /* - * The following functions are polled getc and putc routines, shared - * by the console and kgdb glue. + * The following functions are polled getc and putc routines, used + * by the console glue. */ int @@ -1383,54 +1305,10 @@ comcnpollc(dev_t dev, int on) } #endif /* COM_CONSOLE */ -#ifdef KGDB -int -com_kgdb_attach(bus_space_tag_t iot, bus_addr_t iobase, int rate, - int frequency, tcflag_t cflag) -{ -#ifdef COM_CONSOLE - if (iot == comconsiot && iobase == comconsaddr) { - return (EBUSY); /* cannot share with console */ - } -#endif - - com_kgdb_iot = iot; - com_kgdb_addr = iobase; - - if (bus_space_map(com_kgdb_iot, com_kgdb_addr, COM_NPORTS, 0, - &com_kgdb_ioh)) - panic("com_kgdb_attach: mapping failed"); - - /* XXX We currently don't respect KGDBMODE? */ - cominit(com_kgdb_iot, com_kgdb_ioh, rate, frequency); - - kgdb_attach(com_kgdb_getc, com_kgdb_putc, NULL); - kgdb_dev = 123; /* unneeded, only to satisfy some tests */ - - return (0); -} - -/* ARGSUSED */ -int -com_kgdb_getc(void *arg) -{ - - return (com_common_getc(com_kgdb_iot, com_kgdb_ioh)); -} - -/* ARGSUSED */ -void -com_kgdb_putc(void *arg, int c) -{ - - return (com_common_putc(com_kgdb_iot, com_kgdb_ioh, c)); -} -#endif /* KGDB */ - void com_enable_debugport(struct com_softc *); void com_fifo_probe(struct com_softc *); -#if defined(COM_CONSOLE) || defined(KGDB) +#ifdef COM_CONSOLE void com_enable_debugport(struct com_softc *sc) { @@ -1438,16 +1316,12 @@ com_enable_debugport(struct com_softc *sc) /* Turn on line break interrupt, set carrier. */ s = splhigh(); -#ifdef KGDB - SET(sc->sc_ier, IER_ERXRDY); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_ier, sc->sc_ier); -#endif SET(sc->sc_mcr, MCR_DTR | MCR_RTS | MCR_IENABLE); bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_mcr, sc->sc_mcr); splx(s); } -#endif /* COM_CONSOLE || KGDB */ +#endif /* COM_CONSOLE */ void com_attach_subr(struct com_softc *sc) @@ -1634,21 +1508,8 @@ com_attach_subr(struct com_softc *sc) panic("comattach: bad fifo type"); } -#ifdef KGDB - /* - * Allow kgdb to "take over" this port. If this is - * the kgdb device, it has exclusive use. - */ - - if (iot == com_kgdb_iot && sc->sc_iobase == com_kgdb_addr && - !ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) { - printf("%s: kgdb\n", sc->sc_dev.dv_xname); - SET(sc->sc_hwflags, COM_HW_KGDB); - } -#endif /* KGDB */ - -#if defined(COM_CONSOLE) || defined(KGDB) - if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE|COM_HW_KGDB)) +#ifdef COM_CONSOLE + if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) #endif com_fifo_probe(sc); @@ -1696,8 +1557,8 @@ com_attach_subr(struct com_softc *sc) if (!sc->enable) sc->enabled = 1; -#if defined(COM_CONSOLE) || defined(KGDB) - if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE|COM_HW_KGDB)) +#ifdef COM_CONSOLE + if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) com_enable_debugport(sc); #endif } diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index 28b0f6b99f7..4d38ff78905 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.52 2016/09/03 14:43:37 jsg Exp $ */ +/* $OpenBSD: comvar.h,v 1.53 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -107,7 +107,6 @@ struct com_softc { #define COM_HW_FIFO 0x02 #define COM_HW_SIR 0x20 #define COM_HW_CONSOLE 0x40 -#define COM_HW_KGDB 0x80 u_char sc_swflags; #define COM_SW_SOFTCAR 0x01 #define COM_SW_CLOCAL 0x02 @@ -157,15 +156,6 @@ int com_common_getc(bus_space_tag_t, bus_space_handle_t); void com_common_putc(bus_space_tag_t, bus_space_handle_t, int); void com_raisedtr(void *); -#ifdef KGDB -extern bus_addr_t com_kgdb_addr; -extern bus_space_tag_t com_kgdb_iot; -extern bus_space_handle_t com_kgdb_ioh; - -int com_kgdb_attach(bus_space_tag_t, bus_addr_t, int, int, tcflag_t); -int kgdbintr(void *); -#endif - void com_attach_subr(struct com_softc *); extern int comdefaultrate; diff --git a/sys/dev/ic/z8530sc.h b/sys/dev/ic/z8530sc.h index 9ce5fa6dbee..e9aedc7afe0 100644 --- a/sys/dev/ic/z8530sc.h +++ b/sys/dev/ic/z8530sc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530sc.h,v 1.11 2013/04/21 14:44:16 sebastia Exp $ */ +/* $OpenBSD: z8530sc.h,v 1.12 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: z8530sc.h,v 1.15 2001/05/11 01:40:48 thorpej Exp $ */ /* @@ -156,5 +156,3 @@ int zs_set_speed(struct zs_chanstate *, int); int zs_set_modes(struct zs_chanstate *, int); extern int zs_major; - -int zs_check_kgdb(struct zs_chanstate *, int); diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index 817c82dde0f..d9731e4ff80 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.27 2016/09/04 18:20:34 tedu Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.28 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -315,21 +315,6 @@ zstty_attach(struct device *parent, struct device *self, void *aux) printf(": console%s", i ? (o ? "" : i) : o); } -#ifdef KGDB - if (zs_check_kgdb(cs, dev)) { - /* - * Allow kgdb to "take over" this port. Returns true - * if this serial port is in-use by kgdb. - */ - printf(": kgdb\n"); - /* - * This is the kgdb port (exclusive use) - * so skip the normal attach code. - */ - return; - } -#endif - #if defined(__sparc64__) if (strcmp(args->type, "keyboard") == 0 || strcmp(args->type, "mouse") == 0) diff --git a/sys/dev/isa/com_commulti.c b/sys/dev/isa/com_commulti.c index de586d980d3..9247334d4ab 100644 --- a/sys/dev/isa/com_commulti.c +++ b/sys/dev/isa/com_commulti.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_commulti.c,v 1.4 2008/04/27 09:25:26 kettenis Exp $ */ +/* $OpenBSD: com_commulti.c,v 1.5 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 1997 - 1999, Jason Downs. All rights reserved. * @@ -95,10 +95,6 @@ com_commulti_probe(struct device *parent, void *match, void *aux) iobase = ca->ca_iobase; ioh = ca->ca_ioh; -#ifdef KGDB - if (iobase == com_kgdb_addr) - return (1); -#endif /* if it's in use as console, it's there. */ if (iobase == comconsaddr && !comconsattached) return (1); diff --git a/sys/dev/isa/com_isa.c b/sys/dev/isa/com_isa.c index 6f1c8bb85a1..b7d420a613c 100644 --- a/sys/dev/isa/com_isa.c +++ b/sys/dev/isa/com_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_isa.c,v 1.8 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: com_isa.c,v 1.9 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 1997 - 1999, Jason Downs. All rights reserved. * @@ -91,10 +91,6 @@ com_isa_probe(struct device *parent, void *match, void *aux) iot = ia->ia_iot; iobase = ia->ia_iobase; -#ifdef KGDB - if (iobase == com_kgdb_addr) - goto out; -#endif if (iobase == comconsaddr && !comconsattached) goto out; @@ -129,23 +125,11 @@ com_isa_attach(struct device *parent, struct device *self, void *aux) iobase = ia->ia_iobase; iot = ia->ia_iot; -#ifdef KGDB - if ((iobase != comconsaddr) && - (iobase != com_kgdb_addr)) { -#else if (iobase != comconsaddr) { -#endif if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) panic("com_isa_attach: mapping failed"); } else { -#ifdef KGDB - if (iobase == comconsaddr) - ioh = comconsioh; - else - ioh = com_kgdb_ioh; -#else ioh = comconsioh; -#endif } sc->sc_iot = iot; @@ -157,20 +141,8 @@ com_isa_attach(struct device *parent, struct device *self, void *aux) irq = ia->ia_irq; if (irq != IRQUNK) { -#ifdef KGDB - if (iobase == com_kgdb_addr) { - sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, - IST_EDGE, IPL_HIGH, kgdbintr, sc, - sc->sc_dev.dv_xname); - } else { - sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, - IST_EDGE, IPL_TTY, comintr, sc, - sc->sc_dev.dv_xname); - } -#else sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, IST_EDGE, IPL_TTY, comintr, sc, sc->sc_dev.dv_xname); -#endif /* KGDB */ } } diff --git a/sys/dev/isa/com_isapnp.c b/sys/dev/isa/com_isapnp.c index c247e85d625..6e030839139 100644 --- a/sys/dev/isa/com_isapnp.c +++ b/sys/dev/isa/com_isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_isapnp.c,v 1.4 2008/04/27 09:29:40 kettenis Exp $ */ +/* $OpenBSD: com_isapnp.c,v 1.5 2017/04/30 13:04:49 mpi Exp $ */ /* * Copyright (c) 1997 - 1999, Jason Downs. All rights reserved. * @@ -91,10 +91,6 @@ com_isapnp_probe(struct device *parent, void *match, void *aux) iobase = ia->ia_iobase; ioh = ia->ia_ioh; -#ifdef KGDB - if (iobase == com_kgdb_addr) - return (1); -#endif /* if it's in use as console, it's there. */ if (iobase == comconsaddr && !comconsattached) return (1); @@ -137,20 +133,8 @@ com_isapnp_attach(struct device *parent, struct device *self, void *aux) irq = ia->ia_irq; if (irq != IRQUNK) { -#ifdef KGDB - if (iobase == com_kgdb_addr) { - sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, - IST_EDGE, IPL_HIGH, kgdbintr, sc, - sc->sc_dev.dv_xname); - } else { - sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, - IST_EDGE, IPL_TTY, comintr, sc, - sc->sc_dev.dv_xname); - } -#else sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, IST_EDGE, IPL_TTY, comintr, sc, sc->sc_dev.dv_xname); -#endif /* KGDB */ } } diff --git a/sys/kern/kgdb_stub.c b/sys/kern/kgdb_stub.c deleted file mode 100644 index c894794e6d5..00000000000 --- a/sys/kern/kgdb_stub.c +++ /dev/null @@ -1,540 +0,0 @@ -/* $OpenBSD: kgdb_stub.c,v 1.11 2016/06/07 01:31:54 tedu Exp $ */ -/* $NetBSD: kgdb_stub.c,v 1.6 1998/08/30 20:30:57 scottr Exp $ */ - -/* - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratories. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94 - */ - -/* - * "Stub" to allow remote cpu to debug over a serial line using gdb. - */ - -#include -#include -#include - -/* #define DEBUG_KGDB XXX */ - -/* XXX: Maybe these should be in the MD files? */ -#ifndef KGDBDEV -#define KGDBDEV -1 -#endif -#ifndef KGDBRATE -#define KGDBRATE 19200 -#endif - -int kgdb_dev = KGDBDEV; /* remote debugging device (-1 if none) */ -int kgdb_rate = KGDBRATE; /* remote debugging baud rate */ -int kgdb_active = 0; /* remote debugging active if != 0 */ -int kgdb_debug_init = 0; /* != 0 waits for remote at system init */ -int kgdb_debug_panic = 0; /* != 0 waits for remote on panic */ -label_t *kgdb_recover = 0; - -static void kgdb_copy(void *, void *, int); -/* static void kgdb_zero(void *, int); */ -static void kgdb_send(u_char *); -static int kgdb_recv(u_char *, int); -static int digit2i(u_char); -static u_char i2digit(int); -static void mem2hex(void *, void *, int); -static u_char *hex2mem(void *, u_char *, int); -static vaddr_t hex2i(u_char **); - -static int (*kgdb_getc)(void *); -static void (*kgdb_putc)(void *, int); -static void *kgdb_ioarg; - -static u_char buffer[KGDB_BUFLEN]; -static kgdb_reg_t gdb_regs[KGDB_NUMREGS]; - -#define GETC() ((*kgdb_getc)(kgdb_ioarg)) -#define PUTC(c) ((*kgdb_putc)(kgdb_ioarg, c)) - -/* - * This little routine exists simply so that bcopy() can be debugged. - */ -static void -kgdb_copy(void *vsrc, void *vdst, int len) -{ - char *src = vsrc; - char *dst = vdst; - - while (--len >= 0) - *dst++ = *src++; -} - -#if 0 -/* ditto for bzero */ -static void -kgdb_zero(void *vptr, int len) -{ - char *ptr = vptr; - - while (--len >= 0) - *ptr++ = (char) 0; -} -#endif - -/* - * Convert a hex digit into an integer. - * This returns -1 if the argument passed is no - * valid hex digit. - */ -static int -digit2i(u_char c) -{ - if (c >= '0' && c <= '9') - return (c - '0'); - else if (c >= 'a' && c <= 'f') - return (c - 'a' + 10); - else if (c >= 'A' && c <= 'F') - - return (c - 'A' + 10); - else - return (-1); -} - -/* - * Convert the low 4 bits of an integer into - * an hex digit. - */ -static u_char -i2digit(int n) -{ - return ("0123456789abcdef"[n & 0x0f]); -} - -/* - * Convert a byte array into an hex string. - */ -static void -mem2hex(void *vdst, void *vsrc, int len) -{ - u_char *dst = vdst; - u_char *src = vsrc; - - while (len--) { - *dst++ = i2digit(*src >> 4); - *dst++ = i2digit(*src++); - } - *dst = '\0'; -} - -/* - * Convert an hex string into a byte array. - * This returns a pointer to the character following - * the last valid hex digit. If the string ends in - * the middle of a byte, NULL is returned. - */ -static u_char * -hex2mem(void *vdst, u_char *src, int maxlen) -{ - u_char *dst = vdst; - int msb, lsb; - - while (*src && maxlen--) { - msb = digit2i(*src++); - if (msb < 0) - return (src - 1); - lsb = digit2i(*src++); - if (lsb < 0) - return (NULL); - *dst++ = (msb << 4) | lsb; - } - return (src); -} - -/* - * Convert an hex string into an integer. - * This returns a pointer to the character following - * the last valid hex digit. - */ -static vaddr_t -hex2i(u_char **srcp) -{ - char *src = *srcp; - vaddr_t r = 0; - int nibble; - - while ((nibble = digit2i(*src)) >= 0) { - r *= 16; - r += nibble; - src++; - } - *srcp = src; - return (r); -} - -/* - * Send a packet. - */ -static void -kgdb_send(u_char *bp) -{ - u_char *p; - u_char csum, c; - -#ifdef DEBUG_KGDB - printf("kgdb_send: %s\n", bp); -#endif - do { - p = bp; - PUTC(KGDB_START); - for (csum = 0; (c = *p); p++) { - PUTC(c); - csum += c; - } - PUTC(KGDB_END); - PUTC(i2digit(csum >> 4)); - PUTC(i2digit(csum)); - } while ((c = GETC() & 0x7f) == KGDB_BADP); -} - -/* - * Receive a packet. - */ -static int -kgdb_recv(u_char *bp, int maxlen) -{ - u_char *p; - int c, csum; - int len; - - do { - p = bp; - csum = len = 0; - while ((c = GETC()) != KGDB_START) - continue; - - while ((c = GETC()) != KGDB_END && len < maxlen) { - c &= 0x7f; - csum += c; - *p++ = c; - len++; - } - csum &= 0xff; - *p = '\0'; - - if (len >= maxlen) { - PUTC(KGDB_BADP); - continue; - } - - csum -= digit2i(GETC()) * 16; - csum -= digit2i(GETC()); - - if (csum == 0) { - PUTC(KGDB_GOODP); - /* Sequence present? */ - if (bp[2] == ':') { - PUTC(bp[0]); - PUTC(bp[1]); - len -= 3; - kgdb_copy(bp + 3, bp, len); - } - break; - } - PUTC(KGDB_BADP); - } while (1); -#ifdef DEBUG_KGDB - printf("kgdb_recv: %s\n", bp); -#endif - return (len); -} - -/* - * This is called by the appropriate tty driver. - */ -void -kgdb_attach(int (*getfn)(void *), void (*putfn)(void *, int), void *ioarg) -{ - kgdb_getc = getfn; - kgdb_putc = putfn; - kgdb_ioarg = ioarg; -} - -/* - * This function does all command processing for interfacing to - * a remote gdb. Note that the error codes are ignored by gdb - * at present, but might eventually become meaningful. (XXX) - * It might makes sense to use POSIX errno values, because - * that is what the gdb/remote.c functions want to return. - */ -int -kgdb_trap(int type, db_regs_t *regs) -{ - label_t jmpbuf; - vaddr_t addr; - size_t len; - u_char *p; - - if (kgdb_dev < 0 || kgdb_getc == NULL) { - /* not debugging */ - return (0); - } - - /* Detect and recover from unexpected traps. */ - if (kgdb_recover != 0) { - printf("kgdb: caught trap 0x%x at %p\n", - type, (void *)PC_REGS(regs)); - kgdb_send("E0E"); /* 14==EFAULT */ - longjmp(kgdb_recover); - } - - /* - * The first entry to this function is normally through - * a breakpoint trap in kgdb_connect(), in which case we - * must advance past the breakpoint because gdb will not. - * - * Machines vary as to where they leave the PC after a - * breakpoint trap. Those that leave the PC set to the - * address of the trap instruction (i.e. pc532) will not - * define FIXUP_PC_AFTER_BREAK(), and therefore will just - * advance the PC. On machines that leave the PC set to - * the instruction after the trap, FIXUP_PC_AFTER_BREAK - * will be defined to back-up the PC, so that after the - * "first-time" part of the if statement below has run, - * the PC will be the same as it was on entry. - * - * On the first entry here, we expect that gdb is not yet - * listening to us, so just enter the interaction loop. - * After the debugger is "active" (connected) it will be - * waiting for a "signaled" message from us. - */ - if (kgdb_active == 0) { - if (!IS_BREAKPOINT_TRAP(type, 0)) { - /* No debugger active -- let trap handle this. */ - return (0); - } - /* Make the PC point at the breakpoint... */ -#ifdef FIXUP_PC_AFTER_BREAK - FIXUP_PC_AFTER_BREAK(regs); -#endif - /* ... and then advance past it. */ -#ifdef PC_ADVANCE - PC_ADVANCE(regs); -#else - SET_PC_REGS(regs, PC_REGS(regs) + BKPT_SIZE); -#endif - kgdb_active = 1; - } else { - /* Tell remote host that an exception has occurred. */ - snprintf(buffer, sizeof buffer, "S%02x", kgdb_signal(type)); - kgdb_send(buffer); - } - - /* Stick frame regs into our reg cache. */ - kgdb_getregs(regs, gdb_regs); - - /* - * Interact with gdb until it lets us go. - * If we cause a trap, resume here. - */ - (void)setjmp((kgdb_recover = &jmpbuf)); - for (;;) { - kgdb_recv(buffer, sizeof(buffer)); - switch (buffer[0]) { - - default: - /* Unknown command. */ - kgdb_send(""); - continue; - - case KGDB_SIGNAL: - /* - * if this command came from a running gdb, - * answer it -- the other guy has no way of - * knowing if we're in or out of this loop - * when he issues a "remote-signal". - */ - snprintf(buffer, sizeof buffer, "S%02x", - kgdb_signal(type)); - kgdb_send(buffer); - continue; - - case KGDB_REG_R: - mem2hex(buffer, gdb_regs, sizeof(gdb_regs)); - kgdb_send(buffer); - continue; - - case KGDB_REG_W: - p = hex2mem(gdb_regs, buffer + 1, sizeof(gdb_regs)); - if (p == NULL || *p != '\0') - kgdb_send("E01"); - else { - kgdb_setregs(regs, gdb_regs); - kgdb_send("OK"); - } - continue; - - case KGDB_MEM_R: - p = buffer + 1; - addr = hex2i(&p); - if (*p++ != ',') { - kgdb_send("E02"); - continue; - } - len = hex2i(&p); - if (*p != '\0') { - kgdb_send("E03"); - continue; - } - if (len > sizeof(buffer) / 2) { - kgdb_send("E04"); - continue; - } - if (kgdb_acc(addr, len) == 0) { - kgdb_send("E05"); - continue; - } - db_read_bytes(addr, (size_t)len, - (char *)buffer + sizeof(buffer) / 2); - mem2hex(buffer, buffer + sizeof(buffer) / 2, len); - kgdb_send(buffer); - continue; - - case KGDB_MEM_W: - p = buffer + 1; - addr = hex2i(&p); - if (*p++ != ',') { - kgdb_send("E06"); - continue; - } - len = hex2i(&p); - if (*p++ != ':') { - kgdb_send("E07"); - continue; - } - if (len > (sizeof(buffer) - (p - buffer))) { - kgdb_send("E08"); - continue; - } - p = hex2mem(buffer, p, sizeof(buffer)); - if (p == NULL) { - kgdb_send("E09"); - continue; - } - if (kgdb_acc(addr, len) == 0) { - kgdb_send("E0A"); - continue; - } - db_write_bytes(addr, (size_t)len, (char *)buffer); - kgdb_send("OK"); - continue; - - case KGDB_DETACH: - kgdb_active = 0; - printf("kgdb detached\n"); - db_clear_single_step(regs); - kgdb_send("OK"); - goto out; - - case KGDB_KILL: - kgdb_active = 0; - printf("kgdb detached\n"); - db_clear_single_step(regs); - goto out; - - case KGDB_CONT: - if (buffer[1]) { - p = buffer + 1; - addr = hex2i(&p); - if (*p) { - kgdb_send("E0B"); - continue; - } - SET_PC_REGS(regs, addr); - } - db_clear_single_step(regs); - goto out; - - case KGDB_STEP: - if (buffer[1]) { - p = buffer + 1; - addr = hex2i(&p); - if (*p) { - kgdb_send("E0B"); - continue; - } - SET_PC_REGS(regs, addr); - } - db_set_single_step(regs); - goto out; - } - } - out: - kgdb_recover = 0; - return (1); -} - -/* - * Trap into kgdb to wait for debugger to connect, - * noting on the console why nothing else is going on. - */ -void -kgdb_connect(int verbose) -{ - if (kgdb_dev < 0) - return; - - KGDB_PREPARE; - - if (verbose) - printf("kgdb waiting..."); - - KGDB_ENTER; - - if (verbose) - printf("connected.\n"); - - kgdb_debug_panic = 1; -} - -/* - * Decide what to do on panic. - * (This is called by panic, like Debugger()) - */ -void -kgdb_panic(void) -{ - if (kgdb_dev >= 0 && kgdb_debug_panic) { - printf("entering kgdb\n"); - kgdb_connect(kgdb_active == 0); - } -} diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 8f52a9169c9..d131ca5a187 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_prf.c,v 1.89 2017/04/27 11:48:08 mpi Exp $ */ +/* $OpenBSD: subr_prf.c,v 1.90 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */ /*- @@ -61,9 +61,6 @@ */ #include -#ifdef KGDB -#include -#endif #ifdef DDB #include /* db_printf, db_putchar prototypes */ #include /* db_log, db_radix */ @@ -202,9 +199,6 @@ panic(const char *fmt, ...) printf("\n"); va_end(ap); -#ifdef KGDB - kgdb_panic(); -#endif #ifdef DDB if (db_panic) Debugger(); diff --git a/sys/sys/kgdb.h b/sys/sys/kgdb.h deleted file mode 100644 index 1660667bc45..00000000000 --- a/sys/sys/kgdb.h +++ /dev/null @@ -1,110 +0,0 @@ -/* $OpenBSD: kgdb.h,v 1.5 2005/11/13 17:50:45 fgsch Exp $ */ -/* $NetBSD: kgdb.h,v 1.5 1998/09/13 14:46:24 christos Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratories. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * @(#)remote-sl.h 8.1 (Berkeley) 6/11/93 - */ - -#ifndef _SYS_KGDB_H_ -#define _SYS_KGDB_H_ - -/* - * Protocol definition for KGDB - * (gdb over remote serial line) - */ - -#include - -/* - * Message types. - */ -#define KGDB_MEM_R 'm' -#define KGDB_MEM_W 'M' -#define KGDB_REG_R 'g' -#define KGDB_REG_W 'G' -#define KGDB_CONT 'c' -#define KGDB_STEP 's' -#define KGDB_KILL 'k' -#define KGDB_SIGNAL '?' -#define KGDB_DEBUG 'd' -#define KGDB_DETACH 'D' - -/* - * start of frame/end of frame - */ -#define KGDB_START '$' -#define KGDB_END '#' -#define KGDB_GOODP '+' -#define KGDB_BADP '-' - -#ifdef _KERNEL - -#include -#include - -#ifndef KGDB_PREPARE -#define KGDB_PREPARE -#endif - -#ifndef KGDB_ENTER -#define KGDB_ENTER -#endif - -/* - * Functions and variables exported from kgdb_stub.c - */ -extern int kgdb_dev, kgdb_rate, kgdb_active; -extern int kgdb_debug_init, kgdb_debug_panic; -extern label_t *kgdb_recover; - -void kgdb_attach(int (*)(void *), void (*)(void *, int), void *ioarg); -void kgdb_connect(int); -void kgdb_panic(void); -int kgdb_trap(int, db_regs_t *); - -/* - * Machine dependent functions needed by kgdb_stub.c - */ -int kgdb_signal(int); -int kgdb_acc(vaddr_t, size_t); -void kgdb_getregs(db_regs_t *, kgdb_reg_t *); -void kgdb_setregs(db_regs_t *, kgdb_reg_t *); - -#endif /* _KERNEL */ -#endif /* !_SYS_KGDB_H_ */ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 83a211260e4..4bb3b7ec9ac 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.126 2017/04/20 13:20:17 visa Exp $ */ +/* $OpenBSD: systm.h,v 1.127 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -338,7 +338,7 @@ extern int (*mountroot)(void); #define memmove(d, s, n) __builtin_memmove((d), (s), (n)) #endif -#if defined(DDB) || defined(KGDB) +#if defined(DDB) /* debugger entry points */ void Debugger(void); /* in DDB only */ #endif diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index ae245c51ea4..d1e440b7844 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.141 2017/03/05 00:45:31 guenther Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.142 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -265,9 +265,6 @@ void uao_reference(struct uvm_object *); void uao_reference_locked(struct uvm_object *); int uvm_fault(vm_map_t, vaddr_t, vm_fault_t, vm_prot_t); -#if defined(KGDB) -void uvm_chgkprot(caddr_t, size_t, int); -#endif vaddr_t uvm_uarea_alloc(void); void uvm_uarea_free(struct proc *); void uvm_exit(struct process *); diff --git a/sys/uvm/uvm_glue.c b/sys/uvm/uvm_glue.c index bd2bf466d6d..9098b232fbc 100644 --- a/sys/uvm/uvm_glue.c +++ b/sys/uvm/uvm_glue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_glue.c,v 1.71 2017/02/14 10:31:15 mpi Exp $ */ +/* $OpenBSD: uvm_glue.c,v 1.72 2017/04/30 13:04:49 mpi Exp $ */ /* $NetBSD: uvm_glue.c,v 1.44 2001/02/06 19:54:44 eeh Exp $ */ /* @@ -100,43 +100,6 @@ uvm_kernacc(caddr_t addr, size_t len, int rw) return(rv); } -#ifdef KGDB -/* - * Change protections on kernel pages from addr to addr+len - * (presumably so debugger can plant a breakpoint). - * - * We force the protection change at the pmap level. If we were - * to use vm_map_protect a change to allow writing would be lazily- - * applied meaning we would still take a protection fault, something - * we really don't want to do. It would also fragment the kernel - * map unnecessarily. We cannot use pmap_protect since it also won't - * enforce a write-enable request. Using pmap_enter is the only way - * we can ensure the change takes place properly. - */ -void -uvm_chgkprot(caddr_t addr, size_t len, int rw) -{ - vm_prot_t prot; - paddr_t pa; - vaddr_t sva, eva; - - prot = rw == B_READ ? PROT_READ : PROT_READ | PROT_WRITE; - eva = round_page((vaddr_t)addr + len); - for (sva = trunc_page((vaddr_t)addr); sva < eva; sva += PAGE_SIZE) { - /* - * Extract physical address for the page. - * We use a cheezy hack to differentiate physical - * page 0 from an invalid mapping, not that it - * really matters... - */ - if (pmap_extract(pmap_kernel(), sva, &pa) == FALSE) - panic("chgkprot: invalid page"); - pmap_enter(pmap_kernel(), sva, pa, prot, PMAP_WIRED); - } - pmap_update(pmap_kernel()); -} -#endif - /* * uvm_vslock: wire user memory for I/O * -- 2.20.1