2005/12/21, Justin Pryzby <[EMAIL PROTECTED]>: > Does this bug still apply in recent manpages packages?
Yes. Although not to the same extent as before. PTRACE_GETFPREGS still doesn't exist on ia64. The man page implies it does. It's documented and the documentation says nothing about this function not existing on some platforms. The attached program builds and runs fine on ia32. It doesn't even build on ia64: "error: `PTRACE_GETFPREGS' undeclared". Possibly it's broken on other platforms as well, although the ia64 is the only non-mainstream platform I have access to. Regards //Johan
/* This program attempts to get the FP regs out of another process, * just to see if that's doable. */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <assert.h> #include <sys/ptrace.h> #include <wait.h> #include <stdlib.h> static const char *describeStatus(int status) { static char statusDescription[100]; if (WIFEXITED(status)) { sprintf(statusDescription, "exited with status %d", WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { sprintf(statusDescription, "got terminating signal %d", WTERMSIG(status)); } else if (WIFSTOPPED(status)) { sprintf(statusDescription, "got stop signal %d", WSTOPSIG(status)); } else { sprintf(statusDescription, "received unknown event %#x", status); } return statusDescription; } int main(int argc, char *argv[]) { pid_t childpid; childpid = fork(); assert(childpid >= 0); if (childpid > 0) { // Parent process int status; // Allocate enough space for any CPU's floating point context void *fpregs = malloc(123456); assert(waitpid(childpid, &status, WUNTRACED) == childpid); printf("Parent: Child %s\n", describeStatus(status)); assert(ptrace(PTRACE_GETFPREGS, childpid, NULL, fpregs) == 0); printf("Parent: Successfully fetched floating point registers from child\n"); assert(ptrace(PTRACE_CONT, childpid, 0, 0) == 0); assert(waitpid(childpid, &status, WUNTRACED) == childpid); printf("Parent: Child %s\n", describeStatus(status)); /* assert(waitpid(childpid, &status, WUNTRACED) == childpid); printf("Parent: Child %s\n", describeStatus(status)); */ sleep(2); printf("Parent: Bye!\n"); return 0; } else { // Child process char *runme[] = { "sleep", "3", NULL }; assert(ptrace(PTRACE_TRACEME) == 0); printf("Child %d: exec()ing %s\n", getpid(), runme[0]); execvp(runme[0], runme); /* execl("/bin/sh", "/bin/sh", "-c", "date ; sleep 1", NULL); */ // execlp("date", "date", NULL); // execl("./crashme", "crashme", NULL); perror("exec() failed"); return 1; } }