Home | History | Annotate | Download | only in coregrind

Lines Matching full:child

70    we will generate and patch into the child's address space. */
88 Child;
94 Bool ptrace_READ_BLOCK ( Child* ch, Int len, void* ldst, Addr64 rsrc )
108 Bool ptrace_WRITE_BLOCK ( Child* child, Int len, Addr64 rdst, void* lsrc )
112 r = ptrace64( PT_WRITE_BLOCK, (ULong)child->pid, rdst, len, lsrc );
121 Bool ptrace_READ_GPR ( Child* child, Int reg, ULong* ldst )
126 if (child->is64) {
128 (ULong)child->pid, (ULong)reg, 8, (Int*)(&w64) );
132 (ULong)child->pid, (ULong)reg, 0, 0 );
143 Bool ptrace_WRITE_GPR ( Child* child, Int reg, ULong val )
148 if (child->is64) {
151 (ULong)child->pid, (ULong)reg, 8, (Int*)&w64 );
156 (ULong)child->pid, (ULong)reg, w32, 0 );
255 /* Read a 4096-byte page from CHILD's address space at location SRC,
259 static Bool ptrace_read_page ( Child* child, UChar* ldst, Addr64 rsrc )
267 err = ptrace_READ_BLOCK(child, 1024, ldst + off, rsrc + off);
271 err = ptrace_READ_BLOCK(child, 1024, ldst + off, rsrc + off);
275 err = ptrace_READ_BLOCK(child, 1024, ldst + off, rsrc + off);
279 err = ptrace_READ_BLOCK(child, 1024, ldst + off, rsrc + off);
289 /* Write a 4096-byte page from local address space at SRC to CHILD's
293 static Bool ptrace_write_page ( Child* child, Addr64 rdst, UChar* lsrc )
301 err = ptrace_WRITE_BLOCK(child, 1024, rdst + off, lsrc + off);
305 err = ptrace_WRITE_BLOCK(child, 1024, rdst + off, lsrc + off);
309 err = ptrace_WRITE_BLOCK(child, 1024, rdst + off, lsrc + off);
313 err = ptrace_WRITE_BLOCK(child, 1024, rdst + off, lsrc + off);
324 CHILD into the given array. Returns True if there is any kind of
328 Child* child,
338 err = ptrace_READ_GPR( child, i, &iregs_pc_cr_lr_ctr_xer[j] );
343 err = ptrace_READ_GPR( child, IAR, &iregs_pc_cr_lr_ctr_xer[32+0] );
347 err = ptrace_READ_GPR( child, CR, &iregs_pc_cr_lr_ctr_xer[32+1] );
351 err = ptrace_READ_GPR( child, LR, &iregs_pc_cr_lr_ctr_xer[32+2] );
355 err = ptrace_READ_GPR( child, CTR, &iregs_pc_cr_lr_ctr_xer[32+3] );
359 err = ptrace_READ_GPR( child, XER, &iregs_pc_cr_lr_ctr_xer[32+4] );
366 /* Set CHILD's program counter to the given value. Returns True if
369 Bool ptrace_put_pc ( Child* child, ULong newpc )
371 return ptrace_WRITE_GPR( child, IAR, newpc );
375 /* Set CHILD's R31 to the given value. Returns True if there is any
378 Bool ptrace_put_r31 ( Child* child, ULong newr31 )
380 return ptrace_WRITE_GPR( child, GPR31, newr31 );
597 /* --- BEGIN write bootstrap loader into child
682 AIX5Bootblock structure) into CHILD, so that when
688 ( Child* child, char* toolfile )
710 /* Read some system call entries from the child's
719 "parent: reading child's /proc/../sysent\n");
721 sprintf(sysent_name, "/proc/%d/sysent", child->pid);
724 return "Can't open child's /proc/<pid>/sysent file";
728 return "Error reading child's /proc/<pid>/sysent file";
737 /* Find some syscall numbers for the child. */
740 Int __nr___loadx = -1; /* 32-bit child only */
741 Int __nr_kload = -1; /* 64-bit child only */
770 || ((!child->is64) && __nr___loadx == -1)
771 || ((child->is64) && __nr_kload == -1)
787 /* Continue by copying out the child's current integer register
790 "parent: reading child's int registers\n");
793 ( child, &block.iregs_pc_cr_lr_ctr_xer[0] );
795 return "read of child's int registers failed";
875 if (child->is64) { \
891 if (child->is64) {
1090 /* ------ STEP 3: Find out where to place stuff in the child. ------ */
1094 data section. We can't use the text section, because the child
1098 executable, the child gets SIGKILL'd after the ptrace detach if
1104 child, to find the main executable. */
1107 if (child->is64) {
1108 lr = ptrace64(PT_LDINFO, (ULong)child->pid,
1112 lr = ptrace64(PT_LDINFO, (ULong)child->pid,
1124 if (child->is64) {
1187 if (child->is64) {
1225 err = ptrace_read_page( child, p_page_unzbuf, c_page );
1227 return "read of page from child failed(1)";
1258 err = ptrace_read_page( child, p_page_unzbuf, c_chosen_page );
1260 return "read of page from child failed(2)";
1277 "parent: free space starts at 0x%llx in child\n",
1280 "parent: bootblock will be at 0x%llx in child\n",
1288 err = ptrace_write_page( child, c_chosen_page, p_page_zbuf );
1290 return "write of page to child failed";
1294 err = ptrace_read_page( child, p_page_unzbuf2, c_chosen_page );
1304 "parent: set child's pc to 0x%llx\n",
1306 err = ptrace_put_pc ( child, c_dst + offsetof(AIX5Bootblock,code) );
1308 return "write of new initial pc into child failed";
1311 "parent: set child's r31 to 0x%llx\n", c_dst);
1312 err = ptrace_put_r31 ( child, c_dst );
1314 return "write of new r31 into child failed";
1322 /* --- END write bootstrap loader into child process --- */
1334 Child child;
1350 child.pid = 0;
1351 child.is64 = False;
1369 /* Find some syscall numbers for the child. Note, we copy them
1480 child.is64 = False;
1483 child.is64 = True;
1496 const char* platform = child.is64 ? "ppc64-aix5" : "ppc32-aix5";
1530 environment so that the child can find it. */
1571 In the child, ask for a ptrace, then exec argv[2 ..]. This
1573 child, but does not start it; instead the child remains frozen
1577 child.pid = fork();
1578 if (child.pid == -1) {
1583 if (child.pid == 0) {
1584 /* --- CHILD --- */
1585 VG_(debugLog)(1, "launcher", "child: before ptrace\n");
1588 fprintf(stderr,"%s: child: ptrace(PT_TRACE_ME, ...) failed\n", argv[0]);
1594 VG_(debugLog)(1, "launcher", "child: before execve\n");
1597 VG_(debugLog)(1, "launcher", "child: launcher = %s\n", launcher);
1601 fprintf(stderr,"%s: child: setenv failed\n", argv[0]);
1627 VG_(debugLog)(1, "launcher", "parent: waitpid-ing for child\n");
1629 /* Wait to hear back from the child. */
1630 pid_t p2 = waitpid(child.pid, &status, 0);
1632 successful, and because the child is being ptraced, it is now
1633 waiting for the parent. (2) the exec failed, and so the child
1637 assert(p2 == child.pid); /* Huh?! We only have one child. */
1641 fprintf(stderr, "parent: child's exec failed.\n");
1648 /* ------ BEGIN write bootstrap pages into child ------ */
1651 child-detach and so have to give up, we have to kill the child,
1655 = write_bootstrap_loader_into_child ( &child, toolfile );
1661 /* ------ END write bootstrap pages into child ------ */
1663 VG_(debugLog)(1, "launcher", "parent: detaching child\n");
1664 long lr = ptrace64(PT_DETACH, (ULong)child.pid, 0, SIGCONT, 0);
1667 VG_(debugLog)(1, "launcher", "parent: waiting for child to finish\n");
1669 p2 = waitpid(child.pid, &status, 0);
1670 assert(p2 == child.pid);
1672 fprintf(stderr,"parent: child finished, status 0x%x 0x%x\n",
1677 "parent: child finished normally, exit code %d\n",
1683 "parent: child exited on signal %d\n",
1685 /* Since the child exited with a signal, we'd better
1699 child whilst we still had it latched by ptrace. In this case we