Lines Matching refs:tcp
194 do_ptrace(int request, struct tcb *tcp, void *addr, void *data) in do_ptrace() argument
199 l = ptrace(request, tcp->pid, addr, (long) data); in do_ptrace()
203 tcp->ptrace_errno = ESRCH; in do_ptrace()
215 ptrace_restart(int op, struct tcb *tcp, int sig) in ptrace_restart() argument
221 ptrace(op, tcp->pid, (void *) 1, (long) sig); in ptrace_restart()
226 tcp->ptrace_errno = err; in ptrace_restart()
257 printllval(struct tcb *tcp, const char *format, int llarg) in printllval() argument
267 tprintf(format, tcp->u_arg[llarg]); in printllval()
274 tprintf(format, LONG_LONG(tcp->u_arg[llarg], tcp->u_arg[llarg + 1])); in printllval()
278 tprintf(format, tcp->u_arg[llarg]); in printllval()
281 tprintf(format, tcp->ext_arg[llarg]); in printllval()
284 tprintf(format, LONG_LONG(tcp->u_arg[llarg], tcp->u_arg[llarg + 1])); in printllval()
389 printnum(struct tcb *tcp, long addr, const char *fmt) in printnum() argument
397 if (umove(tcp, addr, &num) < 0) { in printnum()
407 printnum_int(struct tcb *tcp, long addr, const char *fmt) in printnum_int() argument
415 if (umove(tcp, addr, &num) < 0) { in printnum_int()
425 printfd(struct tcb *tcp, int fd) in printfd() argument
557 printpathn(struct tcb *tcp, long addr, int n) in printpathn() argument
571 if (umovestr(tcp, addr, n + 1, path) < 0) in printpathn()
587 printpath(struct tcb *tcp, long addr) in printpath() argument
589 printpathn(tcp, addr, sizeof path - 1); in printpath()
598 printstr(struct tcb *tcp, long addr, int len) in printstr() argument
626 if (umovestr(tcp, addr, size, str) < 0) { in printstr()
633 if (umoven(tcp, addr, size, str) < 0) { in printstr()
648 dumpiov(tcp, len, addr) in dumpiov() argument
649 struct tcb * tcp; in dumpiov()
683 if (umoven(tcp, addr, size, (char *) iov) >= 0) {
689 dumpstr(tcp, (long) iov_iov_base(i),
702 dumpstr(tcp, addr, len) in dumpstr() argument
703 struct tcb *tcp; in dumpstr()
723 if (umoven(tcp, addr, len, (char *) str) < 0)
764 umoven(struct tcb *tcp, long addr, int len, char *laddr) in umoven() argument
767 int pid = tcp->pid; in umoven()
814 int pid = tcp->pid; in umoven()
836 int fd = tcp->pfd_as; in umoven()
838 int fd = tcp->pfd; in umoven()
853 umovestr(struct tcb *tcp, long addr, int len, char *laddr) in umovestr() argument
857 int fd = tcp->pfd_as; in umovestr()
859 int fd = tcp->pfd; in umovestr()
886 int pid = tcp->pid; in umovestr()
1025 upeek(tcp, off, res) in upeek() argument
1026 struct tcb *tcp; in upeek()
1056 val = do_ptrace(PTRACE_PEEKUSER, tcp, (char *) off, 0);
1060 sprintf(buf,"upeek: ptrace(PTRACE_PEEKUSER,%d,%lu,0)", tcp->pid, off);
1072 printcall(struct tcb *tcp) in printcall() argument
1082 if (upeek(tcp, 4*EIP, &eip) < 0) { in printcall()
1090 if(upeek(tcp,PT_PSWADDR,&psw) < 0) { in printcall()
1103 if (upeek(tcp, 8*RIP, &rip) < 0) { in printcall()
1111 if (upeek(tcp, PT_B0, &ip) < 0) { in printcall()
1119 if (upeek(tcp, sizeof(unsigned long)*PT_NIP, &pc) < 0) { in printcall()
1131 if (upeek(tcp, 4*PT_PC, &pc) < 0) { in printcall()
1139 if (upeek(tcp, REG_PC, &pc) < 0) { in printcall()
1146 if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)®s,0) < 0) { in printcall()
1158 if(upeek(tcp,PT_IAOQ0,&pc) < 0) { in printcall()
1166 if (upeek(tcp, REG_EPC, &pc) < 0) { in printcall()
1174 if (upeek(tcp, 4*REG_PC, &pc) < 0) { in printcall()
1182 if (upeek(tcp, REG_PC, &pc) < 0) { in printcall()
1190 if (upeek(tcp, 4*15, &pc) < 0) { in printcall()
1198 if (upeek(tcp, REG_PC, &pc) < 0) { in printcall()
1206 if (upeek(tcp, PT_PC, &pc) < 0) { in printcall()
1214 if (upeek(tcp, 4*PT_IRP, &pc) < 0) { in printcall()
1222 if (upeek(tcp, 4*PT_ERP, &pc) < 0) { in printcall()
1233 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *) ®s, 0) < 0) { in printcall()
1248 pread(tcp->pfd_reg, ®s, sizeof(regs), 0); in printcall()
1288 arg_setup(struct tcb *tcp, arg_setup_state *state) in arg_setup() argument
1299 if (upeek(tcp, PT_AR_BSP, &bsp) < 0) in arg_setup()
1301 if (upeek(tcp, PT_CFM, (long *) &cfm) < 0) in arg_setup()
1312 # define arg_finish_change(tcp, state) 0 argument
1316 get_arg0 (struct tcb *tcp, arg_setup_state *state, long *valp) in get_arg0() argument
1321 ret = upeek (tcp, PT_R11, valp); in get_arg0()
1323 ret = umoven (tcp, in get_arg0()
1330 get_arg1 (struct tcb *tcp, arg_setup_state *state, long *valp) in get_arg1() argument
1335 ret = upeek (tcp, PT_R9, valp); in get_arg1()
1337 ret = umoven (tcp, in get_arg1()
1345 set_arg0 (struct tcb *tcp, arg_setup_state *state, long val) in set_arg0() argument
1356 ptrace(req, tcp->pid, ap, val); in set_arg0()
1361 set_arg1 (struct tcb *tcp, arg_setup_state *state, long val) in set_arg1() argument
1372 ptrace(req, tcp->pid, ap, val); in set_arg1()
1379 # define restore_arg0(tcp, state, val) ((void) (state), 0) argument
1380 # define restore_arg1(tcp, state, val) ((void) (state), 0) argument
1386 # define arg_setup(tcp, state) \ argument
1387 (ptrace (PTRACE_GETREGS, tcp->pid, (char *) (state), 0))
1388 # define arg_finish_change(tcp, state) \ argument
1389 (ptrace (PTRACE_SETREGS, tcp->pid, (char *) (state), 0))
1391 # define get_arg0(tcp, state, valp) (*(valp) = (state)->u_regs[U_REG_O0], 0) argument
1392 # define get_arg1(tcp, state, valp) (*(valp) = (state)->u_regs[U_REG_O1], 0) argument
1393 # define set_arg0(tcp, state, val) ((state)->u_regs[U_REG_O0] = (val), 0) argument
1394 # define set_arg1(tcp, state, val) ((state)->u_regs[U_REG_O1] = (val), 0) argument
1395 # define restore_arg0(tcp, state, val) 0 argument
1406 # define restore_arg0(tcp, state, val) ((void) (state), 0) argument
1407 # define restore_arg1(tcp, state, val) ((void) (state), 0) argument
1419 # define restore_arg0(tcp, state, val) ((void) (state), 0) argument
1433 # define restore_arg0(tcp, state, val) 0 argument
1437 # define restore_arg0(tcp, state, val) 0 argument
1438 # define restore_arg1(tcp, state, val) 0 argument
1445 # define restore_arg0(tcp, state, val) 0 argument
1451 # define arg_setup(tcp, state) (0) argument
1452 # define arg_finish_change(tcp, state) 0 argument
1453 # define get_arg0(tcp, cookie, valp) \ argument
1454 (upeek ((tcp), arg0_offset, (valp)))
1455 # define get_arg1(tcp, cookie, valp) \ argument
1456 (upeek ((tcp), arg1_offset, (valp)))
1459 set_arg0 (struct tcb *tcp, void *cookie, long val) in set_arg0() argument
1461 return ptrace (PTRACE_POKEUSER, tcp->pid, (char*)arg0_offset, val); in set_arg0()
1465 set_arg1 (struct tcb *tcp, void *cookie, long val) in set_arg1() argument
1467 return ptrace (PTRACE_POKEUSER, tcp->pid, (char*)arg1_offset, val); in set_arg1()
1473 # define restore_arg0(tcp, state, val) set_arg0((tcp), (state), (val)) argument
1476 # define restore_arg1(tcp, state, val) set_arg1((tcp), (state), (val)) argument
1485 setbpt(struct tcb *tcp) in setbpt() argument
1490 if (tcp->flags & TCB_BPTSET) { in setbpt()
1491 fprintf(stderr, "PANIC: TCB already set in pid %u\n", tcp->pid); in setbpt()
1509 switch (known_scno(tcp)) { in setbpt()
1517 if (arg_setup (tcp, &state) < 0 in setbpt()
1518 || get_arg0 (tcp, &state, &tcp->inst[0]) < 0 in setbpt()
1519 || get_arg1 (tcp, &state, &tcp->inst[1]) < 0 in setbpt()
1520 || change_syscall(tcp, clone_scno[current_personality]) < 0 in setbpt()
1521 || set_arg0 (tcp, &state, CLONE_PTRACE|SIGCHLD) < 0 in setbpt()
1522 || set_arg1 (tcp, &state, 0) < 0 in setbpt()
1523 || arg_finish_change (tcp, &state) < 0) in setbpt()
1525 tcp->u_arg[arg0_index] = CLONE_PTRACE|SIGCHLD; in setbpt()
1526 tcp->u_arg[arg1_index] = 0; in setbpt()
1527 tcp->flags |= TCB_BPTSET; in setbpt()
1543 if ((arg_setup (tcp, &state) < 0 in setbpt()
1544 || set_arg0 (tcp, &state, in setbpt()
1545 (tcp->u_arg[arg0_index] | CLONE_PTRACE) in setbpt()
1546 & ~(tcp->u_arg[arg0_index] & CLONE_VFORK in setbpt()
1548 || arg_finish_change (tcp, &state) < 0)) in setbpt()
1550 tcp->flags |= TCB_BPTSET; in setbpt()
1551 tcp->inst[0] = tcp->u_arg[arg0_index]; in setbpt()
1552 tcp->inst[1] = tcp->u_arg[arg1_index]; in setbpt()
1557 tcp->scno, tcp->pid); in setbpt()
1565 clearbpt(tcp) in clearbpt() argument
1566 struct tcb *tcp; in clearbpt()
1569 if (arg_setup (tcp, &state) < 0
1570 || restore_arg0 (tcp, &state, tcp->inst[0]) < 0
1571 || restore_arg1 (tcp, &state, tcp->inst[1]) < 0
1572 || arg_finish_change (tcp, &state))
1574 tcp->flags &= ~TCB_BPTSET;
1581 setbpt(tcp) in setbpt() argument
1582 struct tcb *tcp; in setbpt()
1598 if (tcp->flags & TCB_BPTSET) {
1599 fprintf(stderr, "PANIC: TCB already set in pid %u\n", tcp->pid);
1602 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1606 tcp->baddr = regs.r_o7 + 8;
1607 if (ptrace(PTRACE_READTEXT, tcp->pid, (char *)tcp->baddr,
1608 sizeof tcp->inst, (char *)tcp->inst) < 0) {
1623 if (ptrace(PTRACE_WRITETEXT, tcp->pid, (char *) tcp->baddr,
1628 tcp->flags |= TCB_BPTSET;
1637 clearbpt(tcp) in clearbpt() argument
1638 struct tcb *tcp; in clearbpt()
1647 if (!(tcp->flags & TCB_BPTSET)) {
1648 fprintf(stderr, "PANIC: TCB not set in pid %u\n", tcp->pid);
1651 if (ptrace(PTRACE_WRITETEXT, tcp->pid, (char *) tcp->baddr,
1652 sizeof tcp->inst, (char *) tcp->inst) < 0) {
1656 tcp->flags &= ~TCB_BPTSET;
1663 if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
1667 if ((regs.r_pc < tcp->baddr) ||
1668 (regs.r_pc > tcp->baddr + 4)) {
1673 regs.r_pc, tcp->baddr);
1676 if (regs.r_pc != tcp->baddr)
1679 regs.r_pc, tcp->baddr);
1681 regs.r_pc = tcp->baddr;
1682 if (ptrace(PTRACE_SETREGS, tcp->pid, (char *)®s, 0) < 0) {
1701 getex(tcp, hdr) in getex() argument
1702 struct tcb *tcp; in getex()
1709 if (upeek(tcp, uoff(u_exdata) + n, &res) < 0)
1723 fixvfork(tcp) in fixvfork() argument
1724 struct tcb *tcp; in fixvfork()
1726 int pid = tcp->pid;
1737 if (getex(tcp, &hdr) < 0)
1742 if (umove(tcp, (int) N_DATADDR(hdr), &dyn) < 0) {
1746 if (umove(tcp, (int) dyn.ld_un.ld_2, &ld) < 0) {
1754 if (umoven(tcp, (int)ld.ld_symbols+(int)N_TXTADDR(hdr),