Home | History | Annotate | Download | only in strace

Lines Matching full:tcp

474 dumpio(struct tcb *tcp)
476 if (syserror(tcp))
478 if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= MAX_QUALS)
480 if (tcp->scno < 0 || tcp->scno >= nsyscalls)
482 if (sysent[tcp->scno].sys_func == printargs)
484 if (qual_flags[tcp->u_arg[0]] & QUAL_READ) {
485 if (sysent[tcp->scno].sys_func == sys_read ||
486 sysent[tcp->scno].sys_func == sys_pread ||
487 sysent[tcp->scno].sys_func == sys_pread64 ||
488 sysent[tcp->scno].sys_func == sys_recv ||
489 sysent[tcp->scno].sys_func == sys_recvfrom)
490 dumpstr(tcp, tcp->u_arg[1], tcp->u_rval);
491 else if (sysent[tcp->scno].sys_func == sys_readv)
492 dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
495 if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE) {
496 if (sysent[tcp->scno].sys_func == sys_write ||
497 sysent[tcp->scno].sys_func == sys_pwrite ||
498 sysent[tcp->scno].sys_func == sys_pwrite64 ||
499 sysent[tcp->scno].sys_func == sys_send ||
500 sysent[tcp->scno].sys_func == sys_sendto)
501 dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
502 else if (sysent[tcp->scno].sys_func == sys_writev)
503 dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
533 decode_subcall(tcp, subcall, nsubcalls, style)
534 struct tcb *tcp;
545 if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= nsubcalls)
547 tcp->scno = subcall + tcp->u_arg[0];
548 if (sysent[tcp->scno].nargs != -1)
549 tcp->u_nargs = sysent[tcp->scno].nargs;
551 tcp->u_nargs--;
552 for (i = 0; i < tcp->u_nargs; i++)
553 tcp->u_arg[i] = tcp->u_arg[i + 1];
556 if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= nsubcalls)
558 tcp->scno = subcall + tcp->u_arg[0];
559 addr = tcp->u_arg[1];
560 for (i = 0; i < sysent[tcp->scno].nargs; i++) {
563 if (umove(tcp, addr, &arg) < 0)
565 tcp->u_arg[i] = arg;
569 if (umove(tcp, addr, &arg) < 0)
571 tcp->u_arg[i] = arg;
577 tcp->u_nargs = sysent[tcp->scno].nargs;
580 mask = (tcp->u_arg[0] >> 8) & 0xff;
585 tcp->u_arg[0] &= 0xff;
586 tcp->scno = subcall + i;
587 if (sysent[tcp->scno].nargs != -1)
588 tcp->u_nargs = sysent[tcp->scno].nargs;
595 if (tcp->u_arg[5] < 0 || tcp->u_arg[5] >= nsubcalls)
597 tcp->scno = subcall + tcp->u_arg[5];
598 if (sysent[tcp->scno].nargs != -1)
599 tcp->u_nargs = sysent[tcp->scno].nargs;
601 tcp->u_nargs--;
606 if (subcalls_table[i].call == tcp->scno) break;
608 tcp->u_arg[0] >= 0 && tcp->u_arg[0] < subcalls_table[i].nsubcalls) {
609 tcp->scno = subcalls_table[i].subcalls[tcp->u_arg[0]];
610 for (i = 0; i < tcp->u_nargs; i++)
611 tcp->u_arg[i] = tcp->u_arg[i + 1];
622 internal_syscall(struct tcb *tcp)
631 if (tcp->scno < 0 || tcp->scno >= nsyscalls)
634 func = sysent[tcp->scno].sys_func;
637 return internal_exit(tcp);
650 return internal_fork(tcp);
660 return internal_exec(tcp);
671 return internal_wait(tcp, 2);
675 return internal_wait(tcp, 3);
733 get_scno(struct tcb *tcp)
739 if (tcp->flags & TCB_WAITEXECVE) {
749 if (tcp->flags & TCB_INSYSCALL)
755 tcp->flags &= ~TCB_WAITEXECVE;
759 if (upeek(tcp, PT_GPR2, &syscall_mode) < 0)
779 if (upeek(tcp, PT_PSWADDR, &pc) < 0)
782 opcode = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)(pc-sizeof(long)), 0);
813 if (offset_reg && (upeek(tcp, gpr_offset[offset_reg], &tmp) < 0))
819 if (offset_reg && (upeek(tcp, gpr_offset[offset_reg], &tmp) < 0))
823 scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, svc_addr, 0);
833 if (offset_reg && (upeek(tcp, gpr_offset[offset_reg], &tmp) < 0))
840 if (upeek(tcp, sizeof(unsigned long)*PT_R0, &scno) < 0)
842 if (!(tcp->flags & TCB_INSYSCALL)) {
844 if (scno == 0 && (tcp->flags & TCB_WAITEXECVE)) {
845 tcp->flags &= ~TCB_WAITEXECVE;
851 if (!(tcp->flags & TCB_INSYSCALL)) {
854 int pid = tcp->pid;
857 if (upeek(tcp, sizeof (unsigned long)*PT_MSR, &val) < 0)
876 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, &regs) < 0)
882 if (!(tcp->flags & TCB_INSYSCALL)) {
886 if (tcp->flags & TCB_WAITEXECVE) {
887 tcp->flags &= ~TCB_WAITEXECVE;
892 if (upeek(tcp, PT_ORIG_P0, &scno))
895 if (upeek(tcp, 4*ORIG_EAX, &scno) < 0)
898 if (upeek(tcp, 8*ORIG_RAX, &scno) < 0)
901 if (!(tcp->flags & TCB_INSYSCALL)) {
904 int pid = tcp->pid;
912 if (upeek(tcp, 8*CS, &val) < 0)
931 if (upeek(tcp, 8*RIP, &rip) < 0)
965 if (upeek (tcp, PT_CR_IPSR, &psr) >= 0)
967 if (!(tcp->flags & TCB_INSYSCALL)) {
969 if (upeek(tcp, PT_R1, &scno) < 0) /* orig eax */
972 if (upeek (tcp, PT_R15, &scno) < 0)
976 if (tcp->flags & TCB_WAITEXECVE) {
977 tcp->flags &= ~TCB_WAITEXECVE;
982 if (upeek (tcp, PT_R8, &r8) < 0)
984 if (upeek (tcp, PT_R10, &r10) < 0)
991 if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)&regs) == -1)
998 if (!(tcp->flags & TCB_INSYSCALL)) {
1000 if (tcp->flags & TCB_WAITEXECVE) {
1001 tcp->flags &= ~TCB_WAITEXECVE;
1019 scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(regs.ARM_pc - 4), NULL);
1023 if (scno == 0 && (tcp->flags & TCB_WAITEXECVE)) {
1024 tcp->flags &= ~TCB_WAITEXECVE;
1057 if (tcp->flags & TCB_INSYSCALL) {
1058 fprintf(stderr, "pid %d stray syscall entry\n", tcp->pid);
1059 tcp->flags &= ~TCB_INSYSCALL;
1062 if (!(tcp->flags & TCB_INSYSCALL)) {
1063 fprintf(stderr, "pid %d stray syscall exit\n", tcp->pid);
1064 tcp->flags |= TCB_INSYSCALL;
1068 if (upeek(tcp, 4*PT_ORIG_D0, &scno) < 0)
1073 if (ptrace (PTRACE_GETREGS, tcp->pid, NULL, (long) &regs) < 0)
1078 if(!(tcp->flags & TCB_INSYSCALL)) {
1082 if (scno == 0 && tcp->flags & TCB_WAITEXECVE) {
1083 tcp->flags &= ~TCB_WAITEXECVE;
1096 if (upeek(tcp, REG_A3, &a3) < 0)
1098 if(!(tcp->flags & TCB_INSYSCALL)) {
1099 if (upeek(tcp, REG_V0, &scno) < 0)
1103 if (scno == 0 && tcp->flags & TCB_WAITEXECVE) {
1104 tcp->flags &= ~TCB_WAITEXECVE;
1116 if (upeek(tcp, REG_V0, &r2) < 0)
1120 if (upeek(tcp, REG_A3, &a3) < 0)
1123 if (!(tcp->flags & TCB_INSYSCALL)) {
1124 if (upeek(tcp, REG_R0, &scno) < 0)
1128 if (scno == 0 && tcp->flags & TCB_WAITEXECVE) {
1129 tcp->flags &= ~TCB_WAITEXECVE;
1146 if (upeek(tcp, REG_R0, &r0) < 0)
1151 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0)
1155 if (!(tcp->flags & TCB_INSYSCALL)) {
1159 trap = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)regs.tpc, 0);
1162 trap = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)regs.pc, 0);
1195 if(tcp->flags & TCB_WAITEXECVE) {
1196 tcp->flags &= ~TCB_WAITEXECVE;
1218 if (upeek(tcp, PT_GR20, &scno) < 0)
1220 if (!(tcp->flags & TCB_INSYSCALL)) {
1222 if ((tcp->flags & TCB_WAITEXECVE)) {
1223 tcp->flags &= ~TCB_WAITEXECVE;
1231 if (upeek(tcp, 4*(REG_REG0+3), &scno) < 0)
1248 if (!(tcp->flags & TCB_INSYSCALL)) {
1250 if (scno == 0 && tcp->flags & TCB_WAITEXECVE) {
1251 tcp->flags &= ~TCB_WAITEXECVE;
1256 if (upeek(tcp, REG_SYSCALL, &scno) < 0)
1260 if (!(tcp->flags & TCB_INSYSCALL)) {
1262 if (tcp->flags & TCB_WAITEXECVE) {
1263 tcp->flags &= ~TCB_WAITEXECVE;
1268 if (upeek(tcp, 4*PT_R9, &scno) < 0)
1271 if (upeek(tcp, PTREGS_OFFSET_REG(10), &scno) < 0)
1274 if (!(tcp->flags & TCB_INSYSCALL)) {
1276 if (tcp->flags & TCB_WAITEXECVE) {
1277 tcp->flags &= ~TCB_WAITEXECVE;
1282 if (upeek(tcp, 0, &scno) < 0)
1288 if (upeek(tcp, uoff(u_arg[7]), &scno) < 0)
1292 if (upeek(tcp, 4*REG_REG0, (long *)&r0) < 0)
1296 if (upeek(tcp, REG_GENERAL(9), (long *)&r9) < 0)
1302 scno = tcp->status.PR_SYSCALL;
1305 scno = tcp->status.PR_WHAT;
1307 if (pread(tcp->pfd_reg, &regs, sizeof(regs), 0) < 0) {
1314 pread(tcp->pfd, &scno, sizeof(scno), regs.r_esp + sizeof(int));
1324 if (!(tcp->flags & TCB_INSYSCALL))
1325 tcp->scno = scno;
1331 known_scno(struct tcb *tcp)
1333 long scno = tcp->scno;
1351 syscall_fixup(struct tcb *tcp)
1354 int scno = known_scno(tcp);
1356 if (!(tcp->flags & TCB_INSYSCALL)) {
1357 if (tcp->status.PR_WHY != PR_SYSENTRY) {
1377 tcp->status.PR_WHY = PR_SYSENTRY;
1378 trace_syscall(tcp);
1379 tcp->status.PR_WHY = PR_SYSEXIT;
1383 tcp->flags |= TCB_INSYSCALL;
1388 if (tcp->status.PR_WHY != PR_SYSEXIT) {
1390 tcp->flags &= ~TCB_INSYSCALL;
1395 if (!(tcp->flags & TCB_INSYSCALL)) {
1398 tcp->flags |= TCB_INSYSCALL;
1411 tcp->flags &= ~TCB_INSYSCALL;
1417 if (upeek(tcp, 4*EAX, &eax) < 0)
1419 if (eax != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
1425 if (upeek(tcp, 8*RAX, &rax) < 0)
1429 if (rax != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
1435 if (upeek(tcp, PT_GPR2, &gpr2) < 0)
1438 syscall_mode = tcp->scno;
1439 if (gpr2 != syscall_mode && !(tcp->flags & TCB_INSYSCALL)) {
1444 else if (((tcp->flags & (TCB_INSYSCALL|TCB_WAITEXECVE))
1446 && (gpr2 == -ENOSYS || gpr2 == tcp->scno)) {
1455 if (upeek(tcp, sizeof(unsigned long)*PT_CCR, &flags) < 0)
1457 if (upeek(tcp, sizeof(unsigned long)*PT_R3, &result) < 0)
1462 if (upeek(tcp, 4*PT_D0, &d0) < 0)
1464 if (d0 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
1474 if (upeek(tcp, PT_R0, &r0) < 0)
1477 if (upeek(tcp, PT_GR28, &r28) < 0)
1480 if (upeek(tcp, PT_R10, &r10) < 0)
1482 if (upeek(tcp, PT_R8, &r8) < 0)
1484 if (ia32 && r8 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
1490 if (upeek(tcp, 4*PT_R10, &r10) < 0)
1492 if (r10 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
1498 if (upeek(tcp, 3 * 4, &r3) < 0)
1500 if (r3 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
1528 get_error(struct tcb *tcp)
1533 if (tcp->scno >= 0 && tcp->scno < nsyscalls &&
1534 sysent[tcp->scno].sys_flags & SYSCALL_NEVER_FAILS) {
1539 tcp->u_rval = -1;
1543 tcp->u_rval = gpr2;
1548 tcp->u_rval = -1;
1552 tcp->u_rval = eax;
1557 tcp->u_rval = -1;
1561 tcp->u_rval = rax;
1570 tcp->u_rval = -1;
1574 tcp->u_rval = err;
1579 tcp->u_rval = -1;
1582 tcp->u_rval = r8;
1588 tcp->u_rval = -1;
1591 tcp->u_rval = r2;
1596 tcp->u_rval = -1;
1600 tcp->u_rval = result;
1605 tcp->u_rval = -1;
1609 tcp->u_rval = d0;
1614 tcp->u_rval = -1;
1618 tcp->u_rval = regs.ARM_r0;
1623 tcp->u_rval = -1;
1627 tcp->u_rval = regs.r12;
1632 tcp->u_rval = -1;
1635 tcp->u_rval = r0;
1640 tcp->u_rval = -1;
1644 tcp->u_rval = r0;
1649 tcp->u_rval = -1;
1653 tcp->u_rval = regs.u_regs[U_REG_O0];
1658 tcp->u_rval = -1;
1662 tcp->u_rval = regs.u_regs[U_REG_O0];
1667 tcp->u_rval = -1;
1671 tcp->u_rval = r28;
1677 tcp->u_rval = -1;
1681 tcp->u_rval = r0;
1687 tcp->u_rval = -1;
1691 tcp->u_rval = r9;
1696 tcp->u_rval = -1;
1700 tcp->u_rval = r10;
1706 if (upeek(tcp, PTREGS_OFFSET_REG(0), &rval) < 0)
1709 tcp->u_rval = -1;
1713 tcp->u_rval = rval;
1719 tcp->u_rval = -1;
1723 tcp->u_rval = r3;
1730 if (upeek(tcp, uoff(u_error), &u_error) < 0)
1735 if (upeek(tcp, uoff(u_rval1), &tcp->u_rval) < 0)
1741 if (tcp->status.pr_reg[R_PSR] & 0x100000) {
1742 tcp->u_rval = -1;
1743 u_error = tcp->status.pr_reg[R_O0];
1746 tcp->u_rval = tcp->status.pr_reg[R_O0];
1752 if (tcp->status.PR_REG[EFL] & 0x1) {
1753 tcp->u_rval = -1;
1754 u_error = tcp->status.PR_REG[EAX];
1757 tcp->u_rval = tcp->status.PR_REG[EAX];
1759 tcp->u_lrval =
1760 ((unsigned long long) tcp->status.PR_REG[EDX] << 32) +
1761 tcp->status.PR_REG[EAX];
1768 if (tcp->status.PR_REG[EFLAGS] & 0x1) {
1769 tcp->u_rval = -1;
1770 u_error = tcp->status.PR_REG[RAX];
1773 tcp->u_rval = tcp->status.PR_REG[RAX];
1778 if (tcp->status.pr_reg[CTX_A3]) {
1779 tcp->u_rval = -1;
1780 u_error = tcp->status.pr_reg[CTX_V0];
1783 tcp->u_rval = tcp->status.pr_reg[CTX_V0];
1790 tcp->u_rval = -1;
1793 tcp->u_rval = regs.r_eax;
1794 tcp->u_lrval =
1799 tcp->u_error = u_error;
1804 force_result(tcp, error, rval)
1805 struct tcb *tcp;
1812 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)PT_GPR2, gpr2) < 0)
1816 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(EAX * 4), eax) < 0)
1820 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(RAX * 8), rax) < 0)
1825 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R8), r8) < 0)
1837 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R8), r8) < 0 ||
1838 ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R10), r10) < 0)
1843 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)PT_R0, r0) < 0)
1855 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), a3) < 0 ||
1856 ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), r2) < 0)
1859 if (upeek(tcp, sizeof(unsigned long)*PT_CCR, &flags) < 0)
1869 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(sizeof(unsigned long)*PT_CCR), flags) < 0 ||
1870 ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(sizeof(unsigned long)*PT_R3), result) < 0)
1874 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_D0), d0) < 0)
1878 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*0), regs.ARM_r0) < 0)
1882 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)REG_R12, regs.r12) < 0)
1893 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), a3) < 0 ||
1894 ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R0), r0) < 0)
1897 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0)
1907 if (ptrace(PTRACE_SETREGS, tcp->pid, (char *)&regs, 0) < 0)
1910 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0)
1920 if (ptrace(PTRACE_SETREGS, tcp->pid, (char *)&regs, 0) < 0)
1924 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR28), r28) < 0)
1928 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*REG_REG0), r0) < 0)
1932 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)REG_GENERAL(9), r9) < 0)
1938 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)uoff(u_error),
1940 ptrace(PTRACE_POKEUSER, tcp->pid, (char*)uoff(u_rval1), rval) < 0)
1950 if (pread(tcp->pfd_reg, &regs, sizeof(regs), 0) < 0) {
1962 if (pwrite(tcp->pfd_reg, &regs, sizeof(regs), 0) < 0) {
1969 tcp->u_error = error;
1970 tcp->u_rval = rval;
1975 syscall_enter(struct tcb *tcp)
1981 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
1982 tcp->u_nargs = sysent[tcp->scno].nargs;
1984 tcp->u_nargs = MAX_ARGS;
1985 for (i = 0; i < tcp->u_nargs; i++) {
1986 if (upeek(tcp,i==0 ? PT_ORIGGPR2:PT_GPR2+i*sizeof(long), &tcp->u_arg[i]) < 0)
1993 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
1994 tcp->u_nargs = sysent[tcp->scno].nargs;
1996 tcp->u_nargs = MAX_ARGS;
1997 for (i = 0; i < tcp->u_nargs; i++) {
2001 if (upeek(tcp, REG_A0+i, &tcp->u_arg[i]) < 0)
2015 if (upeek(tcp, PT_RBS_END, &rbs_end) < 0)
2017 if (upeek(tcp, PT_CFM, (long *) &cfm) < 0)
2024 if (tcp->scno >= 0 && tcp->scno < nsyscalls
2025 && sysent[tcp->scno].nargs != -1)
2026 tcp->u_nargs = sysent[tcp->scno].nargs;
2028 tcp->u_nargs = MAX_ARGS;
2029 tcp->u_nargs; ++i) {
2030 if (umoven(tcp, (unsigned long) ia64_rse_skip_regs(out0, i),
2031 sizeof(long), (char *) &tcp->u_arg[i]) < 0)
2038 upeek(tcp, PT_R11, (long *) &tcp->u_arg[0]) < 0
2040 || upeek(tcp, PT_R9, (long *) &tcp->u_arg[1]) < 0
2042 || upeek(tcp, PT_R10, (long *) &tcp->u_arg[2]) < 0
2044 || upeek(tcp, PT_R14, (long *) &tcp->u_arg[3]) < 0
2046 || upeek(tcp, PT_R15, (long *) &tcp->u_arg[4]) < 0
2048 || upeek(tcp, PT_R13, (long *) &tcp->u_arg[5]) < 0)
2053 tcp->u_arg[i] &= 0xffffffff;
2055 if (tcp->scno >= 0 && tcp->scno < nsyscalls
2056 && sysent[tcp->scno].nargs != -1)
2057 tcp->u_nargs = sysent[tcp->scno].nargs;
2059 tcp->u_nargs = 5;
2068 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2069 nargs = tcp->u_nargs = sysent[tcp->scno].nargs;
2071 nargs = tcp->u_nargs = MAX_ARGS;
2073 if (ptrace (PTRACE_GETREGS, tcp->pid, NULL, (long) &regs) < 0)
2077 tcp->u_arg[i] = regs[REG_A0 + i];
2079 tcp->ext_arg[i] = regs[REG_A0 + i];
2088 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2089 nargs = tcp->u_nargs = sysent[tcp->scno].nargs;
2091 nargs = tcp->u_nargs = MAX_ARGS;
2093 if(upeek(tcp, REG_SP, &sp) < 0)
2096 if (upeek(tcp, REG_A0 + i, &tcp->u_arg[i])<0)
2099 umoven(tcp, sp+16, (nargs-4) * sizeof(tcp->u_arg[0]),
2100 (char *)(tcp->u_arg + 4));
2103 if (upeek(tcp, REG_A0 + i, &tcp->u_arg[i]) < 0)
2114 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2115 tcp->u_nargs = sysent[tcp->scno].nargs;
2117 tcp->u_nargs = MAX_ARGS;
2118 for (i = 0; i < tcp->u_nargs; i++) {
2119 if (upeek(tcp, (i==0) ?
2122 &tcp->u_arg[i]) < 0)
2130 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2131 tcp->u_nargs = sysent[tcp->scno].nargs;
2133 tcp->u_nargs = MAX_ARGS;
2134 for (i = 0; i < tcp->u_nargs; i++)
2135 tcp->u_arg[i] = regs.u_regs[U_REG_O0 + i];
2141 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2142 tcp->u_nargs = sysent[tcp->scno].nargs;
2144 tcp->u_nargs = MAX_ARGS;
2145 for (i = 0; i < tcp->u_nargs; i++) {
2146 if (upeek(tcp, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
2154 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2155 tcp->u_nargs = sysent[tcp->scno].nargs;
2157 tcp->u_nargs = MAX_ARGS;
2158 for (i = 0; i < tcp->u_nargs; i++)
2159 tcp->u_arg[i] = regs.uregs[i];
2162 tcp->u_nargs = sysent[tcp->scno].nargs;
2163 tcp->u_arg[0] = regs.r12;
2164 tcp->u_arg[1] = regs.r11;
2165 tcp->u_arg[2] = regs.r10;
2166 tcp->u_arg[3] = regs.r9;
2167 tcp->u_arg[4] = regs.r5;
2168 tcp->u_arg[5] = regs.r3;
2174 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2175 tcp->u_nargs = sysent[tcp->scno].nargs;
2177 tcp->u_nargs = sizeof(argreg) / sizeof(argreg[0]);
2179 for (i = 0; i < tcp->u_nargs; ++i)
2180 if (upeek(tcp, argreg[i], &tcp->u_arg[i]) < 0)
2191 tcp->u_nargs = sysent[tcp->scno].nargs;
2192 for (i = 0; i < tcp->u_nargs; i++) {
2193 if (upeek(tcp, 4*syscall_regs[i], &tcp->u_arg[i]) < 0)
2208 assert(sysent[tcp->scno].nargs <
2212 tcp->u_nargs = sysent[tcp->scno].nargs;
2213 for (i = 0; i < tcp->u_nargs; i++) {
2214 if (upeek(tcp, REG_GENERAL(syscall_regs[i]), &tcp->u_arg[i]) < 0)
2227 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2228 tcp->u_nargs = sysent[tcp->scno].nargs;
2230 tcp->u_nargs = MAX_ARGS;
2231 for (i = 0; i < tcp->u_nargs; i++) {
2232 if (upeek(tcp, argreg[current_personality][i]*8, &tcp->u_arg[i]) < 0)
2239 if (tcp->scno >= 0 && tcp->scno < nsyscalls)
2240 tcp->u_nargs = sysent[tcp->scno].nargs;
2242 tcp->u_nargs = 0;
2243 for (i = 0; i < tcp->u_nargs; i++) {
2244 if (upeek(tcp, (5 + i) * 4, &tcp->u_arg[i]) < 0)
2256 if (tcp->scno >= 0 && tcp->scno < nsyscalls)
2257 tcp->u_nargs = sysent[tcp->scno].nargs;
2259 tcp->u_nargs = 0;
2260 for (i = 0; i < tcp->u_nargs; i++) {
2261 if (upeek(tcp, crisregs[i], &tcp->u_arg[i]) < 0)
2268 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2269 tcp->u_nargs = sysent[tcp->scno].nargs;
2271 tcp->u_nargs = MAX_ARGS;
2272 for (i = 0; i < tcp->u_nargs; ++i) {
2273 if (upeek(tcp, PTREGS_OFFSET_REG(i), &tcp->u_arg[i]) < 0)
2280 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2281 tcp->u_nargs = sysent[tcp->scno].nargs;
2283 tcp->u_nargs = MAX_ARGS;
2284 for (i = 0; i < tcp->u_nargs; i++) {
2285 if (upeek(tcp, (i < 5 ? i : i + 2)*4, &tcp->u_arg[i]) < 0)
2292 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2293 tcp->u_nargs = sysent[tcp->scno].nargs;
2295 tcp->u_nargs = MAX_ARGS;
2296 for (i = 0; i < tcp->u_nargs; i++) {
2297 if (upeek(tcp, i*4, &tcp->u_arg[i]) < 0)
2306 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2307 tcp->u_nargs = sysent[tcp->scno].nargs;
2309 tcp->u_nargs = MAX_ARGS;
2310 for (i = 0; i < tcp->u_nargs; i++) {
2313 if (upeek(tcp, uoff(u_arg[0]) +
2314 (i*sizeof(u->u_arg[0])), &tcp->u_arg[i]) < 0)
2325 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2326 tcp->u_nargs = sysent[tcp->scno].nargs;
2328 tcp->u_nargs = tcp->status.pr_nsysarg;
2329 if (tcp->u_nargs > 4) {
2330 memcpy(tcp->u_arg, &tcp->status.pr_reg[CTX_A0],
2331 4*sizeof(tcp->u_arg[0]));
2332 umoven(tcp, tcp->status.pr_reg[CTX_SP] + 16,
2333 (tcp->u_nargs - 4)*sizeof(tcp->u_arg[0]), (char *) (tcp->u_arg + 4));
2336 memcpy(tcp->u_arg, &tcp->status.pr_reg[CTX_A0],
2337 tcp->u_nargs*sizeof(tcp->u_arg[0]));
2343 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2344 tcp->u_nargs = sysent[tcp->scno].nargs;
2346 tcp->u_nargs = tcp->status.pr_lwp.pr_nsysarg;
2347 umoven(tcp, tcp->status.PR_REG[UESP] + 4,
2348 tcp->u_nargs*sizeof(tcp->u_arg[0]), (char *) tcp->u_arg);
2350 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2351 tcp->u_nargs = sysent[tcp->scno].nargs;
2353 tcp->u_nargs = tcp->status.pr_nsysarg;
2356 for (i = 0; i < tcp->u_nargs; i++)
2357 tcp->u_arg[i] = tcp->status.pr_sysarg[i];
2360 if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
2361 tcp->u_nargs = sysent[tcp->scno].nargs;
2363 tcp->u_nargs = 5;
2364 umoven(tcp, tcp->status.PR_REG[UESP] + 4,
2365 tcp->u_nargs*sizeof(tcp->u_arg[0]), (char *) tcp->u_arg);
2371 if (tcp->scno >= 0 && tcp->scno < nsyscalls &&
2372 sysent[tcp->scno].nargs > tcp->status.val)
2373 tcp->u_nargs = sysent[tcp->scno].nargs;
2375 tcp->u_nargs = tcp->status.val;
2376 if (tcp->u_nargs < 0)
2377 tcp->u_nargs = 0;
2378 if (tcp->u_nargs > MAX_ARGS)
2379 tcp->u_nargs = MAX_ARGS;
2382 pread(tcp->pfd, &tcp->u_arg, tcp->u_nargs * sizeof(unsigned long),
2386 pread(tcp->pfd, &tcp->u_arg, tcp->u_nargs * sizeof(unsigned long),
2390 pread(tcp->pfd, &tcp->u_arg, tcp->u_nargs * sizeof(unsigned long),
2399 trace_syscall_exiting(struct tcb *tcp)
2411 * in tcp->something?
2413 scno_good = res = get_scno(tcp);
2417 res = syscall_fixup(tcp);
2421 res = get_error(tcp);
2425 internal_syscall(tcp);
2427 if (res == 1 && tcp->scno >= 0 && tcp->scno < nsyscalls &&
2428 !(qual_flags[tcp->scno] & QUAL_TRACE)) {
2429 tcp->flags &= ~TCB_INSYSCALL;
2433 if (tcp->flags & TCB_REPRINT) {
2434 printleader(tcp);
2438 else if (tcp->scno >= nsyscalls || tcp->scno < 0)
2439 tprintf("syscall_%lu", tcp->scno);
2441 tprintf("%s", sysent[tcp->scno].sys_name);
2447 int rc = count_syscall(tcp, &t);
2450 tcp->flags &= ~TCB_INSYSCALL;
2460 tcp->flags &= ~TCB_INSYSCALL;
2464 if (tcp->scno >= nsyscalls || tcp->scno < 0
2465 || (qual_flags[tcp->scno] & QUAL_RAW))
2466 sys_res = printargs(tcp);
2468 if (not_failing_only && tcp->u_error)
2470 sys_res = (*sysent[tcp->scno].sys_func)(tcp);
2473 u_error = tcp->u_error;
2476 if (tcp->scno >= nsyscalls || tcp->scno < 0 ||
2477 qual_flags[tcp->scno] & QUAL_RAW) {
2481 tprintf("= %#lx", tcp->u_rval);
2511 if ((sys_res & RVAL_STR) && tcp->auxstr)
2512 tprintf(" (%s)", tcp->auxstr);
2520 tprintf("= %#lx", tcp->u_rval);
2523 tprintf("= %#lo", tcp->u_rval);
2526 tprintf("= %lu", tcp->u_rval);
2529 tprintf("= %ld", tcp->u_rval);
2533 tprintf("= %#llx", tcp->u_lrval);
2536 tprintf("= %#llo", tcp->u_lrval);
2539 tprintf("= %llu", tcp->u_lrval);
2542 tprintf("= %lld", tcp->u_lrval);
2551 if ((sys_res & RVAL_STR) && tcp->auxstr)
2552 tprintf(" (%s)", tcp->auxstr);
2555 tv_sub(&tv, &tv, &tcp->etime);
2561 dumpio(tcp);
2562 if (fflush(tcp->outf) == EOF)
2564 tcp->flags &= ~TCB_INSYSCALL;
2569 trace_syscall_entering(struct tcb *tcp)
2574 scno_good = res = get_scno(tcp);
2578 res = syscall_fixup(tcp);
2582 res = syscall_enter(tcp);
2587 printleader(tcp);
2588 tcp->flags &= ~TCB_REPRINT;
2589 tcp_last = tcp;
2592 else if (tcp->scno >= nsyscalls || tcp->scno < 0)
2593 tprintf("syscall_%lu(", tcp->scno);
2595 tprintf("%s(", sysent[tcp->scno].sys_name);
2600 tcp->flags |= TCB_INSYSCALL;
2604 switch (known_scno(tcp)) {
2608 decode_subcall(tcp, SYS_socket_subcall,
2614 decode_subcall(tcp, SYS_ipc_subcall,
2622 decode_subcall(tcp, SYS_pgrpsys_subcall,
2628 decode_subcall(tcp, SYS_sigcall_subcall,
2633 decode_subcall(tcp, SYS_msgsys_subcall,
2637 decode_subcall(tcp, SYS_shmsys_subcall,
2641 decode_subcall(tcp, SYS_semsys_subcall,
2645 decode_subcall(tcp, SYS_sysfs_subcall,
2649 decode_subcall(tcp, SYS_spcall_subcall,
2654 decode_subcall(tcp, SYS_context_subcall,
2660 decode_subcall(tcp, SYS_door_subcall,
2666 decode_subcall(tcp, SYS_kaio_subcall,
2675 decode_subcall(tcp, 0, 0, table_style);
2680 decode_subcall(tcp, SYS_semsys_subcall,
2684 decode_subcall(tcp, SYS_msgsys_subcall,
2688 decode_subcall(tcp, SYS_shmsys_subcall,
2694 internal_syscall(tcp);
2695 if (tcp->scno >=0 && tcp->scno < nsyscalls && !(qual_flags[tcp->scno] & QUAL_TRACE)) {
2696 tcp->flags |= TCB_INSYSCALL;
2701 tcp->flags |= TCB_INSYSCALL;
2702 gettimeofday(&tcp->etime, NULL);
2706 printleader(tcp);
2707 tcp->flags &= ~TCB_REPRINT;
2708 tcp_last = tcp;
2709 if (tcp->scno >= nsyscalls || tcp->scno < 0)
2710 tprintf("syscall_%lu(", tcp->scno);
2712 tprintf("%s(", sysent[tcp->scno].sys_name);
2713 if (tcp->scno >= nsyscalls || tcp->scno < 0 ||
2714 ((qual_flags[tcp->scno] & QUAL_RAW) &&
2715 sysent[tcp->scno].sys_func != sys_exit))
2716 sys_res = printargs(tcp);
2718 sys_res = (*sysent[tcp->scno].sys_func)(tcp);
2719 if (fflush(tcp->outf) == EOF)
2721 tcp->flags |= TCB_INSYSCALL;
2724 gettimeofday(&tcp->etime, NULL);
2729 trace_syscall(struct tcb *tcp)
2731 return exiting(tcp) ?
2732 trace_syscall_exiting(tcp) : trace_syscall_entering(tcp);
2736 printargs(tcp)
2737 struct tcb *tcp;
2739 if (entering(tcp)) {
2742 for (i = 0; i < tcp->u_nargs; i++)
2743 tprintf("%s%#lx", i ? ", " : "", tcp->u_arg[i]);
2749 getrval2(tcp)
2750 struct tcb *tcp;
2757 if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)&regs,0) < 0)
2761 if (upeek(tcp, 4*(REG_REG0+1), &val) < 0)
2764 if (upeek(tcp, PT_R9, &val) < 0)
2770 if (upeek(tcp, uoff(u_rval2), &val) < 0)
2776 val = tcp->status.PR_REG[R_O1];
2779 val = tcp->status.PR_REG[EDX];
2782 val = tcp->status.PR_REG[RDX];
2785 val = tcp->status.PR_REG[CTX_V1];
2791 pread(tcp->pfd_reg, &regs, sizeof(regs), 0);
2803 sys_indir(tcp)
2804 struct tcb *tcp;
2808 if (entering(tcp)) {
2809 if ((scno = tcp->u_arg[0]) > nsyscalls) {
2816 tprintf(", %#lx", tcp->u_arg[i+1]);
2823 is_restart_error(struct tcb *tcp)
2826 if (!syserror(tcp))
2828 switch (tcp->u_error) {