- convert {set, fill}_??regs() and ptrace_single_step() API to taking
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 27 Oct 2005 03:15:47 +0000 (03:15 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 27 Oct 2005 03:15:47 +0000 (03:15 +0000)
  struct lwp instead of struct proc, change their caller accordingly
- in i386/include/md_var.h, add forward declaration of struct lwp and eliminate
  the no longer needed forward declaration of struct proc
- in i386/include/reg.h, add forward declaration of struct lwp and struct proc
- minor style and white space changes

Requested-and-Reviewed-by: corecode
12 files changed:
sys/cpu/i386/include/reg.h
sys/i386/i386/machdep.c
sys/i386/i386/procfs_machdep.c
sys/i386/include/md_var.h
sys/i386/include/reg.h
sys/kern/imgact_elf.c
sys/kern/kern_checkpoint.c
sys/kern/sys_process.c
sys/platform/pc32/i386/machdep.c
sys/platform/pc32/i386/procfs_machdep.c
sys/platform/pc32/include/md_var.h
sys/sys/ptrace.h

index 2a4fbd0..000dfe8 100644 (file)
@@ -35,7 +35,7 @@
  *
  *     from: @(#)reg.h 5.5 (Berkeley) 1/18/91
  * $FreeBSD: src/sys/i386/include/reg.h,v 1.22.2.2 2002/11/07 22:47:55 alfred Exp $
- * $DragonFly: src/sys/cpu/i386/include/reg.h,v 1.3 2003/08/26 21:42:18 rob Exp $
+ * $DragonFly: src/sys/cpu/i386/include/reg.h,v 1.4 2005/10/27 03:15:47 sephe Exp $
  */
 
 #ifndef _MACHINE_REG_H_
@@ -141,13 +141,17 @@ struct dbreg {
 
 
 #ifdef _KERNEL
+
+struct proc;
+struct lwp;
+
 /*
  * XXX these interfaces are MI, so they should be declared in a MI place.
  */
-int    set_fpregs (struct proc *, struct fpreg *);
-int    set_regs (struct proc *p, struct reg *regs);
+int    set_fpregs (struct lwp *, struct fpreg *);
+int    set_regs (struct lwp *lp, struct reg *regs);
 void   setregs (struct proc *, u_long, u_long, u_long);
-int    set_dbregs (struct proc *p, struct dbreg *dbregs);
+int    set_dbregs (struct lwp *lp, struct dbreg *dbregs);
 #endif
 
 #endif /* !_MACHINE_REG_H_ */
index 4e2d1d1..d09e8b9 100644 (file)
@@ -36,7 +36,7 @@
  *
  *     from: @(#)machdep.c     7.4 (Berkeley) 6/3/91
  * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $
- * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.79 2005/10/07 21:55:15 corecode Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.80 2005/10/27 03:15:47 sephe Exp $
  */
 
 #include "use_apm.h"
@@ -2108,10 +2108,9 @@ ptrace_set_pc(p, addr)
 }
 
 int
-ptrace_single_step(p)
-       struct proc *p;
+ptrace_single_step(struct lwp *lp)
 {
-       p->p_md.md_regs->tf_eflags |= PSL_T;
+       lp->lwp_md.md_regs->tf_eflags |= PSL_T;
        return (0);
 }
 
@@ -2175,14 +2174,12 @@ int ptrace_write_u(p, off, data)
 }
 
 int
-fill_regs(p, regs)
-       struct proc *p;
-       struct reg *regs;
+fill_regs(struct lwp *lp, struct reg *regs)
 {
        struct pcb *pcb;
        struct trapframe *tp;
 
-       tp = p->p_md.md_regs;
+       tp = lp->lwp_md.md_regs;
        regs->r_fs = tp->tf_fs;
        regs->r_es = tp->tf_es;
        regs->r_ds = tp->tf_ds;
@@ -2198,20 +2195,18 @@ fill_regs(p, regs)
        regs->r_eflags = tp->tf_eflags;
        regs->r_esp = tp->tf_esp;
        regs->r_ss = tp->tf_ss;
-       pcb = p->p_thread->td_pcb;
+       pcb = lp->lwp_thread->td_pcb;
        regs->r_gs = pcb->pcb_gs;
        return (0);
 }
 
 int
-set_regs(p, regs)
-       struct proc *p;
-       struct reg *regs;
+set_regs(struct lwp *lp, struct reg *regs)
 {
        struct pcb *pcb;
        struct trapframe *tp;
 
-       tp = p->p_md.md_regs;
+       tp = lp->lwp_md.md_regs;
        if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) ||
            !CS_SECURE(regs->r_cs))
                return (EINVAL);
@@ -2230,7 +2225,7 @@ set_regs(p, regs)
        tp->tf_eflags = regs->r_eflags;
        tp->tf_esp = regs->r_esp;
        tp->tf_ss = regs->r_ss;
-       pcb = p->p_thread->td_pcb;
+       pcb = lp->lwp_thread->td_pcb;
        pcb->pcb_gs = regs->r_gs;
        return (0);
 }
@@ -2290,45 +2285,37 @@ set_fpregs_xmm(sv_87, sv_xmm)
 #endif /* CPU_DISABLE_SSE */
 
 int
-fill_fpregs(p, fpregs)
-       struct proc *p;
-       struct fpreg *fpregs;
+fill_fpregs(struct lwp *lp, struct fpreg *fpregs)
 {
 #ifndef CPU_DISABLE_SSE
        if (cpu_fxsr) {
-               fill_fpregs_xmm(&p->p_thread->td_pcb->pcb_save.sv_xmm,
-                                               (struct save87 *)fpregs);
+               fill_fpregs_xmm(&lp->lwp_thread->td_pcb->pcb_save.sv_xmm,
+                               (struct save87 *)fpregs);
                return (0);
        }
 #endif /* CPU_DISABLE_SSE */
-       bcopy(&p->p_thread->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs);
+       bcopy(&lp->lwp_thread->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs);
        return (0);
 }
 
 int
-set_fpregs(p, fpregs)
-       struct proc *p;
-       struct fpreg *fpregs;
+set_fpregs(struct lwp *lp, struct fpreg *fpregs)
 {
 #ifndef CPU_DISABLE_SSE
        if (cpu_fxsr) {
                set_fpregs_xmm((struct save87 *)fpregs,
-                                      &p->p_thread->td_pcb->pcb_save.sv_xmm);
+                              &lp->lwp_thread->td_pcb->pcb_save.sv_xmm);
                return (0);
        }
 #endif /* CPU_DISABLE_SSE */
-       bcopy(fpregs, &p->p_thread->td_pcb->pcb_save.sv_87, sizeof *fpregs);
+       bcopy(fpregs, &lp->lwp_thread->td_pcb->pcb_save.sv_87, sizeof *fpregs);
        return (0);
 }
 
 int
-fill_dbregs(p, dbregs)
-       struct proc *p;
-       struct dbreg *dbregs;
+fill_dbregs(struct lwp *lp, struct dbreg *dbregs)
 {
-       struct pcb *pcb;
-
-        if (p == NULL) {
+        if (lp == NULL) {
                 dbregs->dr0 = rdr0();
                 dbregs->dr1 = rdr1();
                 dbregs->dr2 = rdr2();
@@ -2337,9 +2324,10 @@ fill_dbregs(p, dbregs)
                 dbregs->dr5 = rdr5();
                 dbregs->dr6 = rdr6();
                 dbregs->dr7 = rdr7();
-        }
-        else {
-                pcb = p->p_thread->td_pcb;
+        } else {
+               struct pcb *pcb;
+
+                pcb = lp->lwp_thread->td_pcb;
                 dbregs->dr0 = pcb->pcb_dr0;
                 dbregs->dr1 = pcb->pcb_dr1;
                 dbregs->dr2 = pcb->pcb_dr2;
@@ -2353,15 +2341,9 @@ fill_dbregs(p, dbregs)
 }
 
 int
-set_dbregs(p, dbregs)
-       struct proc *p;
-       struct dbreg *dbregs;
+set_dbregs(struct lwp *lp, struct dbreg *dbregs)
 {
-       struct pcb *pcb;
-       int i;
-       u_int32_t mask1, mask2;
-
-       if (p == NULL) {
+       if (lp == NULL) {
                load_dr0(dbregs->dr0);
                load_dr1(dbregs->dr1);
                load_dr2(dbregs->dr2);
@@ -2370,8 +2352,12 @@ set_dbregs(p, dbregs)
                load_dr5(dbregs->dr5);
                load_dr6(dbregs->dr6);
                load_dr7(dbregs->dr7);
-       }
-       else {
+       } else {
+               struct pcb *pcb;
+               struct ucred *ucred;
+               int i;
+               uint32_t mask1, mask2;
+
                /*
                 * Don't let an illegal value for dr7 get set.  Specifically,
                 * check for undefined settings.  Setting these bit patterns
@@ -2383,8 +2369,9 @@ set_dbregs(p, dbregs)
                        if ((dbregs->dr7 & mask1) == mask2)
                                return (EINVAL);
                
-               pcb = p->p_thread->td_pcb;
-               
+               pcb = lp->lwp_thread->td_pcb;
+               ucred = lp->lwp_proc->p_ucred;
+
                /*
                 * Don't let a process set a breakpoint that is not within the
                 * process's address space.  If a process could do this, it
@@ -2399,40 +2386,40 @@ set_dbregs(p, dbregs)
                 * ... wouldn't that still cause a breakpoint to be generated
                 * from within kernel mode?
                 */
-               
-               if (suser_cred(p->p_ucred, 0) != 0) {
+
+               if (suser_cred(ucred, 0) != 0) {
                        if (dbregs->dr7 & 0x3) {
                                /* dr0 is enabled */
                                if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
-                       
+
                        if (dbregs->dr7 & (0x3<<2)) {
                                /* dr1 is enabled */
                                if (dbregs->dr1 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
-                       
+
                        if (dbregs->dr7 & (0x3<<4)) {
                                /* dr2 is enabled */
                                if (dbregs->dr2 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
-                       
+
                        if (dbregs->dr7 & (0x3<<6)) {
                                /* dr3 is enabled */
                                if (dbregs->dr3 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
                }
-               
+
                pcb->pcb_dr0 = dbregs->dr0;
                pcb->pcb_dr1 = dbregs->dr1;
                pcb->pcb_dr2 = dbregs->dr2;
                pcb->pcb_dr3 = dbregs->dr3;
                pcb->pcb_dr6 = dbregs->dr6;
                pcb->pcb_dr7 = dbregs->dr7;
-               
+
                pcb->pcb_flags |= PCB_DBREGS;
        }
 
index 754fe7c..a01b037 100644 (file)
@@ -38,7 +38,7 @@
  *
  * From:
  * $FreeBSD: src/sys/i386/i386/procfs_machdep.c,v 1.14 1999/10/11 14:50:03 peter Exp $
- * $DragonFly: src/sys/i386/i386/Attic/procfs_machdep.c,v 1.3 2003/08/07 21:17:22 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/procfs_machdep.c,v 1.4 2005/10/27 03:15:47 sephe Exp $
  */
 
 /*
@@ -88,7 +88,7 @@ procfs_read_regs(p, regs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (fill_regs(p, regs));
+       return (fill_regs(&p->p_lwp, regs));
 }
 
 int
@@ -98,7 +98,7 @@ procfs_write_regs(p, regs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (set_regs(p, regs));
+       return (set_regs(&p->p_lwp, regs));
 }
 
 int
@@ -108,7 +108,7 @@ procfs_read_dbregs(p, dbregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (fill_dbregs(p, dbregs));
+       return (fill_dbregs(&p->p_lwp, dbregs));
 }
 
 int
@@ -118,7 +118,7 @@ procfs_write_dbregs(p, dbregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (set_dbregs(p, dbregs));
+       return (set_dbregs(&p->p_lwp, dbregs));
 }
 
 /*
@@ -133,7 +133,7 @@ procfs_read_fpregs(p, fpregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (fill_fpregs(p, fpregs));
+       return (fill_fpregs(&p->p_lwp, fpregs));
 }
 
 int
@@ -143,7 +143,7 @@ procfs_write_fpregs(p, fpregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (set_fpregs(p, fpregs));
+       return (set_fpregs(&p->p_lwp, fpregs));
 }
 
 int
@@ -152,5 +152,5 @@ procfs_sstep(p)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (ptrace_single_step(p));
+       return (ptrace_single_step(&p->p_lwp));
 }
index 73088dc..c1271f9 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/md_var.h,v 1.35.2.4 2003/01/22 20:14:53 jhb Exp $
- * $DragonFly: src/sys/i386/include/Attic/md_var.h,v 1.16 2005/09/23 02:28:50 y0netan1 Exp $
+ * $DragonFly: src/sys/i386/include/Attic/md_var.h,v 1.17 2005/10/27 03:15:47 sephe Exp $
  */
 
 #ifndef _MACHINE_MD_VAR_H_
@@ -62,7 +62,7 @@ extern        char    sigcode[];
 extern int     szsigcode;
 
 typedef void alias_for_inthand_t (u_int cs, u_int ef, u_int esp, u_int ss);
-struct proc;
+struct lwp;
 struct reg;
 struct fpreg;
 struct  dbreg;
@@ -93,9 +93,9 @@ void  doreti_popl_es_fault (void) __asm(__STRING(doreti_popl_es_fault));
 void   doreti_popl_fs (void) __asm(__STRING(doreti_popl_fs));
 void   doreti_popl_fs_fault (void) __asm(__STRING(doreti_popl_fs_fault));
 void   enable_sse (void);
-int    fill_fpregs (struct proc *, struct fpreg *);
-int    fill_regs (struct proc *p, struct reg *regs);
-int    fill_dbregs (struct proc *p, struct dbreg *dbregs);
+int    fill_fpregs (struct lwp *, struct fpreg *);
+int    fill_regs (struct lwp *lp, struct reg *regs);
+int    fill_dbregs (struct lwp *lp, struct dbreg *dbregs);
 void   fillw (int /*u_short*/ pat, void *base, size_t cnt);
 #if 0
 void   i486_bzero (volatile void *buf, size_t len);
index 9be8d5f..ac30770 100644 (file)
@@ -35,7 +35,7 @@
  *
  *     from: @(#)reg.h 5.5 (Berkeley) 1/18/91
  * $FreeBSD: src/sys/i386/include/reg.h,v 1.22.2.2 2002/11/07 22:47:55 alfred Exp $
- * $DragonFly: src/sys/i386/include/Attic/reg.h,v 1.3 2003/08/26 21:42:18 rob Exp $
+ * $DragonFly: src/sys/i386/include/Attic/reg.h,v 1.4 2005/10/27 03:15:47 sephe Exp $
  */
 
 #ifndef _MACHINE_REG_H_
@@ -141,13 +141,17 @@ struct dbreg {
 
 
 #ifdef _KERNEL
+
+struct proc;
+struct lwp;
+
 /*
  * XXX these interfaces are MI, so they should be declared in a MI place.
  */
-int    set_fpregs (struct proc *, struct fpreg *);
-int    set_regs (struct proc *p, struct reg *regs);
+int    set_fpregs (struct lwp *, struct fpreg *);
+int    set_regs (struct lwp *lp, struct reg *regs);
 void   setregs (struct proc *, u_long, u_long, u_long);
-int    set_dbregs (struct proc *p, struct dbreg *dbregs);
+int    set_dbregs (struct lwp *lp, struct dbreg *dbregs);
 #endif
 
 #endif /* !_MACHINE_REG_H_ */
index 021bcce..b142701 100644 (file)
@@ -27,7 +27,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/imgact_elf.c,v 1.73.2.13 2002/12/28 19:49:41 dillon Exp $
- * $DragonFly: src/sys/kern/imgact_elf.c,v 1.32 2005/09/02 07:16:58 hsu Exp $
+ * $DragonFly: src/sys/kern/imgact_elf.c,v 1.33 2005/10/27 03:15:47 sephe Exp $
  */
 
 #include <sys/param.h>
@@ -1225,9 +1225,9 @@ elf_corehdr(struct proc *p, struct file *fp, struct ucred *cred, int numsegs,
        status->pr_osreldate = osreldate;
        status->pr_cursig = p->p_sig;
        status->pr_pid = p->p_pid;
-       fill_regs(p, &status->pr_reg);
+       fill_regs(&p->p_lwp, &status->pr_reg);
 
-       fill_fpregs(p, fpregset);
+       fill_fpregs(&p->p_lwp, fpregset);
 
        psinfo->pr_version = PRPSINFO_VERSION;
        psinfo->pr_psinfosz = sizeof(prpsinfo_t);
index ef21e5d..c62c234 100644 (file)
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/sys/kern/kern_checkpoint.c,v 1.5 2005/08/09 02:49:49 hmp Exp $
+ * $DragonFly: src/sys/kern/kern_checkpoint.c,v 1.6 2005/10/27 03:15:47 sephe Exp $
  */
 
 #include <sys/types.h>
@@ -301,9 +301,9 @@ elf_loadnotes(struct proc *p, prpsinfo_t *psinfo, prstatus_t *status,
                error = EINVAL;
                goto done;
        }
-       if ((error = set_regs(p, &status->pr_reg)) != 0)
+       if ((error = set_regs(&p->p_lwp, &status->pr_reg)) != 0)
                goto done;
-       error = set_fpregs(p, fpregset);
+       error = set_fpregs(&p->p_lwp, fpregset);
        strlcpy(p->p_comm, psinfo->pr_fname, sizeof(p->p_comm));
        /* XXX psinfo->pr_psargs not yet implemented */
  done: 
index c219033..001862b 100644 (file)
@@ -29,7 +29,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/kern/sys_process.c,v 1.51.2.6 2003/01/08 03:06:45 kan Exp $
- * $DragonFly: src/sys/kern/sys_process.c,v 1.16 2005/06/06 15:35:28 dillon Exp $
+ * $DragonFly: src/sys/kern/sys_process.c,v 1.17 2005/10/27 03:15:47 sephe Exp $
  */
 
 #include <sys/param.h>
@@ -407,7 +407,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data, int *re
                PHOLD(p);
 
                if (req == PT_STEP) {
-                       if ((error = ptrace_single_step (p))) {
+                       if ((error = ptrace_single_step (&p->p_lwp))) {
                                PRELE(p);
                                return error;
                        }
index d461755..902659e 100644 (file)
@@ -36,7 +36,7 @@
  *
  *     from: @(#)machdep.c     7.4 (Berkeley) 6/3/91
  * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $
- * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.79 2005/10/07 21:55:15 corecode Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.80 2005/10/27 03:15:47 sephe Exp $
  */
 
 #include "use_apm.h"
@@ -2108,10 +2108,9 @@ ptrace_set_pc(p, addr)
 }
 
 int
-ptrace_single_step(p)
-       struct proc *p;
+ptrace_single_step(struct lwp *lp)
 {
-       p->p_md.md_regs->tf_eflags |= PSL_T;
+       lp->lwp_md.md_regs->tf_eflags |= PSL_T;
        return (0);
 }
 
@@ -2175,14 +2174,12 @@ int ptrace_write_u(p, off, data)
 }
 
 int
-fill_regs(p, regs)
-       struct proc *p;
-       struct reg *regs;
+fill_regs(struct lwp *lp, struct reg *regs)
 {
        struct pcb *pcb;
        struct trapframe *tp;
 
-       tp = p->p_md.md_regs;
+       tp = lp->lwp_md.md_regs;
        regs->r_fs = tp->tf_fs;
        regs->r_es = tp->tf_es;
        regs->r_ds = tp->tf_ds;
@@ -2198,20 +2195,18 @@ fill_regs(p, regs)
        regs->r_eflags = tp->tf_eflags;
        regs->r_esp = tp->tf_esp;
        regs->r_ss = tp->tf_ss;
-       pcb = p->p_thread->td_pcb;
+       pcb = lp->lwp_thread->td_pcb;
        regs->r_gs = pcb->pcb_gs;
        return (0);
 }
 
 int
-set_regs(p, regs)
-       struct proc *p;
-       struct reg *regs;
+set_regs(struct lwp *lp, struct reg *regs)
 {
        struct pcb *pcb;
        struct trapframe *tp;
 
-       tp = p->p_md.md_regs;
+       tp = lp->lwp_md.md_regs;
        if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) ||
            !CS_SECURE(regs->r_cs))
                return (EINVAL);
@@ -2230,7 +2225,7 @@ set_regs(p, regs)
        tp->tf_eflags = regs->r_eflags;
        tp->tf_esp = regs->r_esp;
        tp->tf_ss = regs->r_ss;
-       pcb = p->p_thread->td_pcb;
+       pcb = lp->lwp_thread->td_pcb;
        pcb->pcb_gs = regs->r_gs;
        return (0);
 }
@@ -2290,45 +2285,37 @@ set_fpregs_xmm(sv_87, sv_xmm)
 #endif /* CPU_DISABLE_SSE */
 
 int
-fill_fpregs(p, fpregs)
-       struct proc *p;
-       struct fpreg *fpregs;
+fill_fpregs(struct lwp *lp, struct fpreg *fpregs)
 {
 #ifndef CPU_DISABLE_SSE
        if (cpu_fxsr) {
-               fill_fpregs_xmm(&p->p_thread->td_pcb->pcb_save.sv_xmm,
-                                               (struct save87 *)fpregs);
+               fill_fpregs_xmm(&lp->lwp_thread->td_pcb->pcb_save.sv_xmm,
+                               (struct save87 *)fpregs);
                return (0);
        }
 #endif /* CPU_DISABLE_SSE */
-       bcopy(&p->p_thread->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs);
+       bcopy(&lp->lwp_thread->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs);
        return (0);
 }
 
 int
-set_fpregs(p, fpregs)
-       struct proc *p;
-       struct fpreg *fpregs;
+set_fpregs(struct lwp *lp, struct fpreg *fpregs)
 {
 #ifndef CPU_DISABLE_SSE
        if (cpu_fxsr) {
                set_fpregs_xmm((struct save87 *)fpregs,
-                                      &p->p_thread->td_pcb->pcb_save.sv_xmm);
+                              &lp->lwp_thread->td_pcb->pcb_save.sv_xmm);
                return (0);
        }
 #endif /* CPU_DISABLE_SSE */
-       bcopy(fpregs, &p->p_thread->td_pcb->pcb_save.sv_87, sizeof *fpregs);
+       bcopy(fpregs, &lp->lwp_thread->td_pcb->pcb_save.sv_87, sizeof *fpregs);
        return (0);
 }
 
 int
-fill_dbregs(p, dbregs)
-       struct proc *p;
-       struct dbreg *dbregs;
+fill_dbregs(struct lwp *lp, struct dbreg *dbregs)
 {
-       struct pcb *pcb;
-
-        if (p == NULL) {
+        if (lp == NULL) {
                 dbregs->dr0 = rdr0();
                 dbregs->dr1 = rdr1();
                 dbregs->dr2 = rdr2();
@@ -2337,9 +2324,10 @@ fill_dbregs(p, dbregs)
                 dbregs->dr5 = rdr5();
                 dbregs->dr6 = rdr6();
                 dbregs->dr7 = rdr7();
-        }
-        else {
-                pcb = p->p_thread->td_pcb;
+        } else {
+               struct pcb *pcb;
+
+                pcb = lp->lwp_thread->td_pcb;
                 dbregs->dr0 = pcb->pcb_dr0;
                 dbregs->dr1 = pcb->pcb_dr1;
                 dbregs->dr2 = pcb->pcb_dr2;
@@ -2353,15 +2341,9 @@ fill_dbregs(p, dbregs)
 }
 
 int
-set_dbregs(p, dbregs)
-       struct proc *p;
-       struct dbreg *dbregs;
+set_dbregs(struct lwp *lp, struct dbreg *dbregs)
 {
-       struct pcb *pcb;
-       int i;
-       u_int32_t mask1, mask2;
-
-       if (p == NULL) {
+       if (lp == NULL) {
                load_dr0(dbregs->dr0);
                load_dr1(dbregs->dr1);
                load_dr2(dbregs->dr2);
@@ -2370,8 +2352,12 @@ set_dbregs(p, dbregs)
                load_dr5(dbregs->dr5);
                load_dr6(dbregs->dr6);
                load_dr7(dbregs->dr7);
-       }
-       else {
+       } else {
+               struct pcb *pcb;
+               struct ucred *ucred;
+               int i;
+               uint32_t mask1, mask2;
+
                /*
                 * Don't let an illegal value for dr7 get set.  Specifically,
                 * check for undefined settings.  Setting these bit patterns
@@ -2383,8 +2369,9 @@ set_dbregs(p, dbregs)
                        if ((dbregs->dr7 & mask1) == mask2)
                                return (EINVAL);
                
-               pcb = p->p_thread->td_pcb;
-               
+               pcb = lp->lwp_thread->td_pcb;
+               ucred = lp->lwp_proc->p_ucred;
+
                /*
                 * Don't let a process set a breakpoint that is not within the
                 * process's address space.  If a process could do this, it
@@ -2399,40 +2386,40 @@ set_dbregs(p, dbregs)
                 * ... wouldn't that still cause a breakpoint to be generated
                 * from within kernel mode?
                 */
-               
-               if (suser_cred(p->p_ucred, 0) != 0) {
+
+               if (suser_cred(ucred, 0) != 0) {
                        if (dbregs->dr7 & 0x3) {
                                /* dr0 is enabled */
                                if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
-                       
+
                        if (dbregs->dr7 & (0x3<<2)) {
                                /* dr1 is enabled */
                                if (dbregs->dr1 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
-                       
+
                        if (dbregs->dr7 & (0x3<<4)) {
                                /* dr2 is enabled */
                                if (dbregs->dr2 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
-                       
+
                        if (dbregs->dr7 & (0x3<<6)) {
                                /* dr3 is enabled */
                                if (dbregs->dr3 >= VM_MAXUSER_ADDRESS)
                                        return (EINVAL);
                        }
                }
-               
+
                pcb->pcb_dr0 = dbregs->dr0;
                pcb->pcb_dr1 = dbregs->dr1;
                pcb->pcb_dr2 = dbregs->dr2;
                pcb->pcb_dr3 = dbregs->dr3;
                pcb->pcb_dr6 = dbregs->dr6;
                pcb->pcb_dr7 = dbregs->dr7;
-               
+
                pcb->pcb_flags |= PCB_DBREGS;
        }
 
index 4a5a5f9..8c514a6 100644 (file)
@@ -38,7 +38,7 @@
  *
  * From:
  * $FreeBSD: src/sys/i386/i386/procfs_machdep.c,v 1.14 1999/10/11 14:50:03 peter Exp $
- * $DragonFly: src/sys/platform/pc32/i386/procfs_machdep.c,v 1.3 2003/08/07 21:17:22 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/procfs_machdep.c,v 1.4 2005/10/27 03:15:47 sephe Exp $
  */
 
 /*
@@ -88,7 +88,7 @@ procfs_read_regs(p, regs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (fill_regs(p, regs));
+       return (fill_regs(&p->p_lwp, regs));
 }
 
 int
@@ -98,7 +98,7 @@ procfs_write_regs(p, regs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (set_regs(p, regs));
+       return (set_regs(&p->p_lwp, regs));
 }
 
 int
@@ -108,7 +108,7 @@ procfs_read_dbregs(p, dbregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (fill_dbregs(p, dbregs));
+       return (fill_dbregs(&p->p_lwp, dbregs));
 }
 
 int
@@ -118,7 +118,7 @@ procfs_write_dbregs(p, dbregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (set_dbregs(p, dbregs));
+       return (set_dbregs(&p->p_lwp, dbregs));
 }
 
 /*
@@ -133,7 +133,7 @@ procfs_read_fpregs(p, fpregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (fill_fpregs(p, fpregs));
+       return (fill_fpregs(&p->p_lwp, fpregs));
 }
 
 int
@@ -143,7 +143,7 @@ procfs_write_fpregs(p, fpregs)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (set_fpregs(p, fpregs));
+       return (set_fpregs(&p->p_lwp, fpregs));
 }
 
 int
@@ -152,5 +152,5 @@ procfs_sstep(p)
 {
        if ((p->p_flag & P_INMEM) == 0)
                return (EIO);
-       return (ptrace_single_step(p));
+       return (ptrace_single_step(&p->p_lwp));
 }
index 8058525..05ced6e 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/md_var.h,v 1.35.2.4 2003/01/22 20:14:53 jhb Exp $
- * $DragonFly: src/sys/platform/pc32/include/md_var.h,v 1.16 2005/09/23 02:28:50 y0netan1 Exp $
+ * $DragonFly: src/sys/platform/pc32/include/md_var.h,v 1.17 2005/10/27 03:15:47 sephe Exp $
  */
 
 #ifndef _MACHINE_MD_VAR_H_
@@ -62,7 +62,7 @@ extern        char    sigcode[];
 extern int     szsigcode;
 
 typedef void alias_for_inthand_t (u_int cs, u_int ef, u_int esp, u_int ss);
-struct proc;
+struct lwp;
 struct reg;
 struct fpreg;
 struct  dbreg;
@@ -93,9 +93,9 @@ void  doreti_popl_es_fault (void) __asm(__STRING(doreti_popl_es_fault));
 void   doreti_popl_fs (void) __asm(__STRING(doreti_popl_fs));
 void   doreti_popl_fs_fault (void) __asm(__STRING(doreti_popl_fs_fault));
 void   enable_sse (void);
-int    fill_fpregs (struct proc *, struct fpreg *);
-int    fill_regs (struct proc *p, struct reg *regs);
-int    fill_dbregs (struct proc *p, struct dbreg *dbregs);
+int    fill_fpregs (struct lwp *, struct fpreg *);
+int    fill_regs (struct lwp *lp, struct reg *regs);
+int    fill_dbregs (struct lwp *lp, struct dbreg *dbregs);
 void   fillw (int /*u_short*/ pat, void *base, size_t cnt);
 #if 0
 void   i486_bzero (volatile void *buf, size_t len);
index 9a35619..af73eff 100644 (file)
@@ -32,7 +32,7 @@
  *
  *     @(#)ptrace.h    8.2 (Berkeley) 1/4/94
  * $FreeBSD: src/sys/sys/ptrace.h,v 1.10.2.2 2003/01/02 20:39:13 kan Exp $
- * $DragonFly: src/sys/sys/ptrace.h,v 1.5 2004/02/25 17:38:51 joerg Exp $
+ * $DragonFly: src/sys/sys/ptrace.h,v 1.6 2005/10/27 03:15:47 sephe Exp $
  */
 
 #ifndef        _SYS_PTRACE_H_
@@ -74,7 +74,7 @@ struct ptrace_io_desc {
 #ifdef _KERNEL
 void   proc_reparent (struct proc *child, struct proc *newparent);
 int    ptrace_set_pc (struct proc *p, unsigned long addr);
-int    ptrace_single_step (struct proc *p);
+int    ptrace_single_step (struct lwp *lp);
 int    ptrace_write_u (struct proc *p, vm_offset_t off, long data);
 int    kern_ptrace (struct proc *p, int req, pid_t pid, void *addr,
                int data, int *res);