From owner-svn-src-head@FreeBSD.ORG Fri Jun 12 15:14:10 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2E47856C; Fri, 12 Jun 2015 15:14:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C4E8898; Fri, 12 Jun 2015 15:14:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5CFE9Ds049789; Fri, 12 Jun 2015 15:14:09 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5CFE9Fu049784; Fri, 12 Jun 2015 15:14:09 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201506121514.t5CFE9Fu049784@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 12 Jun 2015 15:14:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284325 - in head/sys: amd64/amd64 i386/i386 i386/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jun 2015 15:14:10 -0000 Author: jhb Date: Fri Jun 12 15:14:08 2015 New Revision: 284325 URL: https://svnweb.freebsd.org/changeset/base/284325 Log: Report the values of x86 segment registers to remote debuggers. While here, also report %eflags from the i386 trapframe. Differential Revision: https://reviews.freebsd.org/D2743 Reviewed by: kib Obtained from: 1 month Modified: head/sys/amd64/amd64/gdb_machdep.c head/sys/i386/i386/gdb_machdep.c head/sys/i386/i386/machdep.c head/sys/i386/include/gdb_machdep.h Modified: head/sys/amd64/amd64/gdb_machdep.c ============================================================================== --- head/sys/amd64/amd64/gdb_machdep.c Fri Jun 12 15:06:17 2015 (r284324) +++ head/sys/amd64/amd64/gdb_machdep.c Fri Jun 12 15:14:08 2015 (r284325) @@ -48,6 +48,8 @@ __FBSDID("$FreeBSD$"); void * gdb_cpu_getreg(int regnum, size_t *regsz) { + static uint32_t _kcodesel = GSEL(GCODE_SEL, SEL_KPL); + static uint32_t _kdatasel = GSEL(GDATA_SEL, SEL_KPL); *regsz = gdb_cpu_regsz(regnum); @@ -76,6 +78,8 @@ gdb_cpu_getreg(int regnum, size_t *regsz case 14: return (&kdb_thrctx->pcb_r14); case 15: return (&kdb_thrctx->pcb_r15); case 16: return (&kdb_thrctx->pcb_rip); + case 18: return (&_kcodesel); + case 19: return (&_kdatasel); } return (NULL); } Modified: head/sys/i386/i386/gdb_machdep.c ============================================================================== --- head/sys/i386/i386/gdb_machdep.c Fri Jun 12 15:06:17 2015 (r284324) +++ head/sys/i386/i386/gdb_machdep.c Fri Jun 12 15:14:08 2015 (r284325) @@ -45,14 +45,22 @@ __FBSDID("$FreeBSD$"); void * gdb_cpu_getreg(int regnum, size_t *regsz) { + static uint32_t _kcodesel = GSEL(GCODE_SEL, SEL_KPL); + static uint32_t _kdatasel = GSEL(GDATA_SEL, SEL_KPL); + static uint32_t _kprivsel = GSEL(GPRIV_SEL, SEL_KPL); *regsz = gdb_cpu_regsz(regnum); - if (kdb_thread == curthread) { + if (kdb_thread == curthread) { switch (regnum) { case 0: return (&kdb_frame->tf_eax); case 1: return (&kdb_frame->tf_ecx); case 2: return (&kdb_frame->tf_edx); + case 9: return (&kdb_frame->tf_eflags); + case 10: return (&kdb_frame->tf_cs); + case 12: return (&kdb_frame->tf_ds); + case 13: return (&kdb_frame->tf_es); + case 14: return (&kdb_frame->tf_fs); } } switch (regnum) { @@ -62,6 +70,12 @@ gdb_cpu_getreg(int regnum, size_t *regsz case 6: return (&kdb_thrctx->pcb_esi); case 7: return (&kdb_thrctx->pcb_edi); case 8: return (&kdb_thrctx->pcb_eip); + case 10: return (&_kcodesel); + case 11: return (&_kdatasel); + case 12: return (&_kdatasel); + case 13: return (&_kdatasel); + case 14: return (&_kprivsel); + case 15: return (&kdb_thrctx->pcb_gs); } return (NULL); } Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Fri Jun 12 15:06:17 2015 (r284324) +++ head/sys/i386/i386/machdep.c Fri Jun 12 15:14:08 2015 (r284325) @@ -2867,6 +2867,7 @@ makectx(struct trapframe *tf, struct pcb pcb->pcb_ebx = tf->tf_ebx; pcb->pcb_eip = tf->tf_eip; pcb->pcb_esp = (ISPL(tf->tf_cs)) ? tf->tf_esp : (int)(tf + 1) - 8; + pcb->pcb_gs = rgs(); } int Modified: head/sys/i386/include/gdb_machdep.h ============================================================================== --- head/sys/i386/include/gdb_machdep.h Fri Jun 12 15:06:17 2015 (r284324) +++ head/sys/i386/include/gdb_machdep.h Fri Jun 12 15:14:08 2015 (r284325) @@ -30,7 +30,7 @@ #define _MACHINE_GDB_MACHDEP_H_ #define GDB_BUFSZ 400 -#define GDB_NREGS 14 +#define GDB_NREGS 16 #define GDB_REG_PC 8 static __inline size_t