Date: Fri, 11 Aug 2006 03:56:39 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 103625 for review Message-ID: <200608110356.k7B3udkp006771@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=103625 Change 103625 by marcel@marcel_nfs on 2006/08/11 03:56:05 Provide backward compatible defaults. Affected files ... .. //depot/projects/gdb/sys/fs/procfs/procfs_dbregs.c#5 edit .. //depot/projects/gdb/sys/fs/procfs/procfs_fpregs.c#5 edit .. //depot/projects/gdb/sys/fs/procfs/procfs_regs.c#5 edit Differences ... ==== //depot/projects/gdb/sys/fs/procfs/procfs_dbregs.c#5 (text+ko) ==== @@ -55,6 +55,8 @@ #include <sys/sysent.h> #include <sys/uio.h> +#include <machine/reg.h> + #include <fs/pseudofs/pseudofs.h> #include <fs/procfs/procfs.h> @@ -62,9 +64,16 @@ extern struct sysentvec ia32_freebsd_sysvec; #endif +static struct ptregset default_dbreg = { + .rs_size = sizeof(struct dbreg), + .rs_read = (ptregset_readf)fill_dbregs, + .rs_write = (ptregset_writef)set_dbregs +}; + int procfs_doprocdbregs(PFS_FILL_ARGS) { + struct ptregset *rs; struct sysentvec *sv; struct thread *td2; void *buf; @@ -77,41 +86,35 @@ return (EPERM); } - /* XXXKSE: */ - td2 = FIRST_THREAD_IN_PROC(p); - sv = td2->td_proc->p_sysent; + sv = p->p_sysent; + rs = (sv->sv_dbreg != NULL) ? sv->sv_dbreg : &default_dbreg; + PROC_UNLOCK(p); - if (sv->sv_dbreg == NULL) { - PROC_UNLOCK(p); - return (ENXIO); - } #ifdef COMPAT_IA32 if (td->td_proc->p_sysent == &ia32_freebsd_sysvec && - sv != &ia32_freebsd_sysvec) { - PROC_UNLOCK(p); + sv != &ia32_freebsd_sysvec) return (EINVAL); - } #endif - PROC_UNLOCK(p); - buf = malloc(sv->sv_dbreg->rs_size, M_TEMP, M_WAITOK); + buf = malloc(rs->rs_size, M_TEMP, M_WAITOK); if (buf == NULL) return (ENOMEM); PROC_LOCK(p); - error = ptrace_read_regf(td2, buf, sv->sv_dbreg->rs_read); + /* XXXKSE: */ + td2 = FIRST_THREAD_IN_PROC(p); + error = ptrace_read_regf(td2, buf, rs->rs_read); if (error == 0) { PROC_UNLOCK(p); - error = uiomove_frombuf(buf, sv->sv_dbreg->rs_size, uio); + error = uiomove_frombuf(buf, rs->rs_size, uio); PROC_LOCK(p); } if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (!P_SHOULDSTOP(p)) /* XXXKSE should be P_TRACED? */ + if (!P_SHOULDSTOP(p)) error = EBUSY; else /* XXXKSE: */ - error = ptrace_write_regf(td2, buf, - sv->sv_dbreg->rs_write); + error = ptrace_write_regf(td2, buf, rs->rs_write); } PROC_UNLOCK(p); ==== //depot/projects/gdb/sys/fs/procfs/procfs_fpregs.c#5 (text+ko) ==== @@ -49,6 +49,8 @@ #include <sys/sysent.h> #include <sys/uio.h> +#include <machine/reg.h> + #include <fs/pseudofs/pseudofs.h> #include <fs/procfs/procfs.h> @@ -56,9 +58,16 @@ extern struct sysentvec ia32_freebsd_sysvec; #endif +static struct ptregset default_fpreg = { + .rs_size = sizeof(struct fpreg), + .rs_read = (ptregset_readf)fill_fpregs, + .rs_write = (ptregset_writef)set_fpregs +}; + int procfs_doprocfpregs(PFS_FILL_ARGS) { + struct ptregset *rs; struct sysentvec *sv; struct thread *td2; void *buf; @@ -71,33 +80,27 @@ return (EPERM); } - /* XXXKSE: */ - td2 = FIRST_THREAD_IN_PROC(p); - sv = td2->td_proc->p_sysent; - - if (sv->sv_fpreg == NULL) { - PROC_UNLOCK(p); - return (ENXIO); - } + sv = p->p_sysent; + rs = (sv->sv_fpreg != NULL) ? sv->sv_fpreg : &default_fpreg; + PROC_UNLOCK(p); #ifdef COMPAT_IA32 if (td->td_proc->p_sysent == &ia32_freebsd_sysvec && - sv != &ia32_freebsd_sysvec) { - PROC_UNLOCK(p); + sv != &ia32_freebsd_sysvec) return (EINVAL); - } #endif - PROC_UNLOCK(p); - buf = malloc(sv->sv_fpreg->rs_size, M_TEMP, M_WAITOK); + buf = malloc(rs->rs_size, M_TEMP, M_WAITOK); if (buf == NULL) return (ENOMEM); PROC_LOCK(p); - error = ptrace_read_regf(td2, buf, sv->sv_fpreg->rs_read); + /* XXXKSE: */ + td2 = FIRST_THREAD_IN_PROC(p); + error = ptrace_read_regf(td2, buf, rs->rs_read); if (error == 0) { PROC_UNLOCK(p); - error = uiomove_frombuf(buf, sv->sv_fpreg->rs_size, uio); + error = uiomove_frombuf(buf, rs->rs_size, uio); PROC_LOCK(p); } if (error == 0 && uio->uio_rw == UIO_WRITE) { @@ -105,8 +108,7 @@ error = EBUSY; else /* XXXKSE: */ - error = ptrace_write_regf(td2, buf, - sv->sv_fpreg->rs_write); + error = ptrace_write_regf(td2, buf, rs->rs_write); } PROC_UNLOCK(p); ==== //depot/projects/gdb/sys/fs/procfs/procfs_regs.c#5 (text+ko) ==== @@ -49,6 +49,8 @@ #include <sys/sysent.h> #include <sys/uio.h> +#include <machine/reg.h> + #include <fs/pseudofs/pseudofs.h> #include <fs/procfs/procfs.h> @@ -56,9 +58,16 @@ extern struct sysentvec ia32_freebsd_sysvec; #endif +static struct ptregset default_reg = { + .rs_size = sizeof(struct reg), + .rs_read = (ptregset_readf)fill_regs, + .rs_write = (ptregset_writef)set_regs +}; + int procfs_doprocregs(PFS_FILL_ARGS) { + struct ptregset *rs; struct sysentvec *sv; struct thread *td2; void *buf; @@ -71,33 +80,27 @@ return (EPERM); } - /* XXXKSE: */ - td2 = FIRST_THREAD_IN_PROC(p); - sv = td2->td_proc->p_sysent; - - if (sv->sv_reg == NULL) { - PROC_UNLOCK(p); - return (ENXIO); - } + sv = p->p_sysent; + rs = (sv->sv_reg != NULL) ? sv->sv_reg : &default_reg; + PROC_UNLOCK(p); #ifdef COMPAT_IA32 if (td->td_proc->p_sysent == &ia32_freebsd_sysvec && - sv != &ia32_freebsd_sysvec) { - PROC_UNLOCK(p); + sv != &ia32_freebsd_sysvec) return (EINVAL); - } #endif - PROC_UNLOCK(p); - buf = malloc(sv->sv_reg->rs_size, M_TEMP, M_WAITOK); + buf = malloc(rs->rs_size, M_TEMP, M_WAITOK); if (buf == NULL) return (ENOMEM); PROC_LOCK(p); - error = ptrace_read_regf(td2, buf, sv->sv_reg->rs_read); + /* XXXKSE: */ + td2 = FIRST_THREAD_IN_PROC(p); + error = ptrace_read_regf(td2, buf, rs->rs_read); if (error == 0) { PROC_UNLOCK(p); - error = uiomove_frombuf(buf, sv->sv_reg->rs_size, uio); + error = uiomove_frombuf(buf, rs->rs_size, uio); PROC_LOCK(p); } if (error == 0 && uio->uio_rw == UIO_WRITE) { @@ -105,8 +108,7 @@ error = EBUSY; else /* XXXKSE: */ - error = ptrace_write_regf(td2, buf, - sv->sv_reg->rs_write); + error = ptrace_write_regf(td2, buf, rs->rs_write); } PROC_UNLOCK(p);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608110356.k7B3udkp006771>