Messages in this thread | | | From | Shourya Sarcar <> | Subject | ptrace : newbie problem | Date | Tue, 14 Mar 2000 08:21:02 +0530 |
| |
Hello ! The following piece of code gives me and error while doing the ptrace (PTRACE_PEEKDATA,....) call. Why ? strace shows an EIO error. Any clues, anybody ? The same thing happens if I do the call with PEEKTEXT (gee, the source code treats the DATA and TEXT identically arch/i386/kernel/ptrace.c) I want to read the Data portion and store it onto a file for some process checkpointing. Clues, pointers, will be helpful.
o I had to include <linux/ptrace.h> to get the PTRACE_PEEKUSR macro. o Please send me a cc of your reply as I am not subscribed to the list.
______________ fork.c _______________
#include <unistd.h> #include <stdio.h> #include <sys/ptrace.h> #include <linux/ptrace.h> #include <wait.h> int main() { int pid, ppid,cpid; int st,err; long data[20];
pid=getpid(); ppid=getppid(); printf("Father %d, ME %d\n",ppid,pid); cpid=fork(); if(cpid==0) { /*child*/ pid=getpid(); ppid=getppid(); printf("Father %d, ME %d\n",ppid,pid); while(1);// { printf("."); } } getchar(); // force delay err=ptrace(PTRACE_ATTACH,cpid,0,0); if (err==0) printf("Attached child\n"); waitpid(cpid,&st,WUNTRACED); err=ptrace(PTRACE_PEEKDATA,cpid,st,data); if (err==0) { /* Correct read */ printf("Read at %d with err =%d\n",st,err); getchar(); } else /* ptrace sets err to -1 on error */ printf("Place %d : Err = %d\n",st,err); err=ptrace(PTRACE_DETACH,cpid,0,0); while(1); } ___________________________________________________________
-- ____________________________________________________________ One thing is clear. Fuzzy logic is here to stay.
Shourya Sarcar Dept. of Computer Science Jadavpur University, Calcutta, India Res : 364/3 Netaji Subhas Chandra Bose Road, India 700 047 Tel : 91-033-471 0477 ____________________________________________________________
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |