http://www.alexonlinux.com/how-debugger-works
先藏着,以后学习。
原文中的代码有一点错。应该改成这样。
+ /* and restore the original instruction */
+ ptrace(PTRACE_POKETEXT, child, (void *)addr, orig_data);
+
/* Debuggie is now ready to get resumed... Waiting ten seconds... */
printf("Time before debugger falling asleep: %ld\n", (long)time(NULL));
sleep(5);
printf("Time after debugger falling asleep: %ld. Resuming debuggie...\n", (long)time(NULL));