Tuesday, April 24, 2012

Issues about stepping through the code of a process on mac os x

In by debugger process, by using ptrace(PT_STEP,childPid,0,0), tell the OS to restart the child process, but stop it after it executes the next instruction.



But seems that the result is not right. Child process do not executes the next instruction,but in my debugger process, i called wait(&statue) after the call:ptrace(PT_STEP,childPid,0,0).



wait(&wait_status);
while (WIFSTOPPED(wait_status)) {
if (ptrace(PT_STEP, child, 0, 0) < 0) {
perror("ptrace");
return;
}
wait(&wait_status);
//Read the data using vm_read at address:0x10046 in process debugie's memory space,compare with the orig value.
//But, the new value is always same as the orig value!!!
}


In debugie process, i set: data= data*10; the data's address is 0x10046.
After several steps,the new value should be different from the orig value, i changed data's value several time in debugie process.



I test it on Mac os x, but it's a virtual machine(Virtual Box).





No comments:

Post a Comment