Lines Matching refs:cp

142 	cstatus_t *cp;
216 if ((cp = GrabProc(pid)) == NULLCP)
219 ps = &cp->pstatus;
221 if (ProcUpdate(cp) != 0) {
222 ReleaseProc(cp);
238 if (pread(cp->asfd, (char *)&data, sizeof (data), (off_t)addr)
252 GetPsargs(cp);
254 GetSignal(cp);
257 data = *((int *)((caddr_t)(&cp->user) + xaddr));
268 if (xaddr >= (unsigned)cp->user.u_reg[REG_SP] &&
269 xaddr < (unsigned)cp->user.u_reg[REG_SP]+16*sizeof (int))
270 cp->flags |= CS_SETREGS;
271 if (pwrite(cp->asfd, (char *)&data, sizeof (data), (off_t)addr)
287 data = (cp->user.u_reg[REG_PS] &
291 cp->user.u_reg[rx] = data;
292 cp->flags |= CS_SETREGS;
303 if (cp->flags & CS_SETREGS) {
307 ps->pr_lwp.pr_reg[R_PSR] = cp->user.u_reg[REG_PSR];
308 ps->pr_lwp.pr_reg[R_PC] = cp->user.u_reg[REG_PC];
309 ps->pr_lwp.pr_reg[R_nPC] = cp->user.u_reg[REG_nPC];
310 ps->pr_lwp.pr_reg[R_Y] = cp->user.u_reg[REG_Y];
311 ps->pr_lwp.pr_reg[R_G1] = cp->user.u_reg[REG_G1];
312 ps->pr_lwp.pr_reg[R_G2] = cp->user.u_reg[REG_G2];
313 ps->pr_lwp.pr_reg[R_G3] = cp->user.u_reg[REG_G3];
314 ps->pr_lwp.pr_reg[R_G4] = cp->user.u_reg[REG_G4];
315 ps->pr_lwp.pr_reg[R_G5] = cp->user.u_reg[REG_G5];
316 ps->pr_lwp.pr_reg[R_G6] = cp->user.u_reg[REG_G6];
317 ps->pr_lwp.pr_reg[R_G7] = cp->user.u_reg[REG_G7];
318 ps->pr_lwp.pr_reg[R_O0] = cp->user.u_reg[REG_O0];
319 ps->pr_lwp.pr_reg[R_O1] = cp->user.u_reg[REG_O1];
320 ps->pr_lwp.pr_reg[R_O2] = cp->user.u_reg[REG_O2];
321 ps->pr_lwp.pr_reg[R_O3] = cp->user.u_reg[REG_O3];
322 ps->pr_lwp.pr_reg[R_O4] = cp->user.u_reg[REG_O4];
323 ps->pr_lwp.pr_reg[R_O5] = cp->user.u_reg[REG_O5];
324 ps->pr_lwp.pr_reg[R_O6] = cp->user.u_reg[REG_O6];
325 ps->pr_lwp.pr_reg[R_O7] = cp->user.u_reg[REG_O7];
326 (void) pread(cp->asfd, (char *)&ps->pr_lwp.pr_reg[R_L0],
327 16*sizeof (int), (off_t)cp->user.u_reg[REG_SP]);
333 if (writev(cp->ctlfd, iov, 2) < 0)
337 (addr & ~03) != cp->user.u_reg[REG_PC]) {
340 if (write(cp->ctlfd, (char *)runctl, 2*sizeof (long))
350 if (write(cp->ctlfd, (char *)&ctl,
361 if (write(cp->ctlfd, (char *)runctl, 3*sizeof (long))
365 ReleaseProc(cp);
372 cp->flags = 0;
382 (void) write(cp->ctlfd, (char *)&ctl,
385 ReleaseProc(cp);
395 if (OpenProc(cp) == 0)
397 ReleaseProc(cp);
415 cstatus_t *cp;
417 for (cp = childp; cp != NULLCP; cp = cp->next)
418 if (cp->pid == pid)
421 return (cp);
431 cstatus_t *cp = childp;
433 while (cp != NULLCP) {
434 cstatus_t *next = cp->next;
436 if (ProcUpdate(cp) != 0)
437 ReleaseProc(cp);
438 cp = next;
485 OpenProc(cstatus_t *cp)
492 MakeProcName(procname, cp->pid);
498 omode = (cp->asfd > 0)? O_RDWR : (O_RDWR|O_EXCL);
501 (cp->asfd = Dupfd(fd, cp->asfd)) < 0)
506 (cp->ctlfd = Dupfd(fd, cp->ctlfd)) < 0)
511 (cp->statusfd = Dupfd(fd, cp->statusfd)) < 0)
517 CloseProc(cp);
525 CloseProc(cstatus_t *cp)
527 if (cp->asfd > 0)
528 (void) close(cp->asfd);
529 if (cp->ctlfd > 0)
530 (void) close(cp->ctlfd);
531 if (cp->statusfd > 0)
532 (void) close(cp->statusfd);
533 cp->asfd = 0;
534 cp->ctlfd = 0;
535 cp->statusfd = 0;
544 cstatus_t *cp;
551 if ((cp = FindProc(pid)) != NULLCP) /* already grabbed */
552 return (cp);
556 cp = (cstatus_t *)malloc(sizeof (cstatus_t));
557 if (cp == NULLCP)
559 (void) memset((char *)cp, 0, sizeof (cstatus_t));
560 cp->pid = pid;
563 while (OpenProc(cp) == 0) {
568 if (pread(cp->statusfd, (char *)&cp->pstatus,
569 sizeof (cp->pstatus), (off_t)0) == sizeof (cp->pstatus) &&
570 cp->pstatus.pr_ppid == ppid &&
571 (cp->pstatus.pr_flags & PR_PTRACE) &&
572 write(cp->ctlfd, (char *)ctl, 2*sizeof (long))
574 cp->next = childp;
575 childp = cp;
576 MakeUser(cp);
577 return (cp);
584 free((char *)cp);
593 ReleaseProc(cstatus_t *cp)
595 CloseProc(cp);
597 if (childp == cp)
598 childp = cp->next;
603 if (pcp->next == cp) {
604 pcp->next = cp->next;
610 free((char *)cp);
618 ProcUpdate(cstatus_t *cp)
620 pstatus_t *ps = &cp->pstatus;
622 if (cp->flags & CS_SETREGS) {
626 ps->pr_lwp.pr_reg[R_PSR] = cp->user.u_reg[REG_PSR];
627 ps->pr_lwp.pr_reg[R_PC] = cp->user.u_reg[REG_PC];
628 ps->pr_lwp.pr_reg[R_nPC] = cp->user.u_reg[REG_nPC];
629 ps->pr_lwp.pr_reg[R_Y] = cp->user.u_reg[REG_Y];
630 ps->pr_lwp.pr_reg[R_G1] = cp->user.u_reg[REG_G1];
631 ps->pr_lwp.pr_reg[R_G2] = cp->user.u_reg[REG_G2];
632 ps->pr_lwp.pr_reg[R_G3] = cp->user.u_reg[REG_G3];
633 ps->pr_lwp.pr_reg[R_G4] = cp->user.u_reg[REG_G4];
634 ps->pr_lwp.pr_reg[R_G5] = cp->user.u_reg[REG_G5];
635 ps->pr_lwp.pr_reg[R_G6] = cp->user.u_reg[REG_G6];
636 ps->pr_lwp.pr_reg[R_G7] = cp->user.u_reg[REG_G7];
637 ps->pr_lwp.pr_reg[R_O0] = cp->user.u_reg[REG_O0];
638 ps->pr_lwp.pr_reg[R_O1] = cp->user.u_reg[REG_O1];
639 ps->pr_lwp.pr_reg[R_O2] = cp->user.u_reg[REG_O2];
640 ps->pr_lwp.pr_reg[R_O3] = cp->user.u_reg[REG_O3];
641 ps->pr_lwp.pr_reg[R_O4] = cp->user.u_reg[REG_O4];
642 ps->pr_lwp.pr_reg[R_O5] = cp->user.u_reg[REG_O5];
643 ps->pr_lwp.pr_reg[R_O6] = cp->user.u_reg[REG_O6];
644 ps->pr_lwp.pr_reg[R_O7] = cp->user.u_reg[REG_O7];
645 (void) pread(cp->asfd, (char *)&ps->pr_lwp.pr_reg[R_L0],
646 16*sizeof (int), (off_t)cp->user.u_reg[REG_SP]);
652 (void) writev(cp->ctlfd, iov, 2);
653 cp->flags &= ~CS_SETREGS;
656 while (pread(cp->statusfd, (char *)ps, sizeof (*ps), (off_t)0) < 0) {
659 !(errno == EAGAIN && OpenProc(cp) == 0))
664 MakeUser(cp);
675 MakeUser(cstatus_t *cp)
677 pstatus_t *ps = &cp->pstatus;
679 cp->user.u_reg[REG_PSR] = ps->pr_lwp.pr_reg[R_PSR];
680 cp->user.u_reg[REG_PC] = ps->pr_lwp.pr_reg[R_PC];
681 cp->user.u_reg[REG_nPC] = ps->pr_lwp.pr_reg[R_nPC];
682 cp->user.u_reg[REG_Y] = ps->pr_lwp.pr_reg[R_Y];
683 cp->user.u_reg[REG_G1] = ps->pr_lwp.pr_reg[R_G1];
684 cp->user.u_reg[REG_G2] = ps->pr_lwp.pr_reg[R_G2];
685 cp->user.u_reg[REG_G3] = ps->pr_lwp.pr_reg[R_G3];
686 cp->user.u_reg[REG_G4] = ps->pr_lwp.pr_reg[R_G4];
687 cp->user.u_reg[REG_G5] = ps->pr_lwp.pr_reg[R_G5];
688 cp->user.u_reg[REG_G6] = ps->pr_lwp.pr_reg[R_G6];
689 cp->user.u_reg[REG_G7] = ps->pr_lwp.pr_reg[R_G7];
690 cp->user.u_reg[REG_O0] = ps->pr_lwp.pr_reg[R_O0];
691 cp->user.u_reg[REG_O1] = ps->pr_lwp.pr_reg[R_O1];
692 cp->user.u_reg[REG_O2] = ps->pr_lwp.pr_reg[R_O2];
693 cp->user.u_reg[REG_O3] = ps->pr_lwp.pr_reg[R_O3];
694 cp->user.u_reg[REG_O4] = ps->pr_lwp.pr_reg[R_O4];
695 cp->user.u_reg[REG_O5] = ps->pr_lwp.pr_reg[R_O5];
696 cp->user.u_reg[REG_O6] = ps->pr_lwp.pr_reg[R_O6];
697 cp->user.u_reg[REG_O7] = ps->pr_lwp.pr_reg[R_O7];
698 cp->user.u_ar0 = (greg_t *)REGADDR;
699 cp->user.u_code = ps->pr_lwp.pr_info.si_code;
700 cp->user.u_addr = ps->pr_lwp.pr_info.si_addr;
701 cp->flags &= ~(CS_PSARGS|CS_SIGNAL);
708 GetPsargs(cstatus_t *cp)
713 MakeProcName(procname, cp->pid);
716 (void) memset(cp->user.u_psargs, 0, PSARGSZ);
719 (void) pread(fd, cp->user.u_psargs, PSARGSZ,
723 cp->flags |= CS_PSARGS;
730 GetSignal(cstatus_t *cp)
737 MakeProcName(procname, cp->pid);
745 cp->user.u_signal[i] = action[i].sa_handler;
746 cp->flags |= CS_SIGNAL;