I understand that strace command uses ptrace(PTRACE_PEEKUSER, child, __builtin_offsetof(struct user, regs.orig_eax)) to find the index of a system call the tracee child is trapped at. Then to translate the index into the syscall function name, it has built up tables made from grepping the linux source code headers present in the installation.
This method must be undocumented and prone to failure because the location and syntax of source code declarations are not documented, must be found by grepping and may change in unknown ways. Am I correct to say that?
If that is so, then why would strace not use the following method, with seems to me, is simpler, relies only on documentation and is thus foolproof.
At the start of the first run after reboot, strace sends out a test syscall, one for each syscall function, traps that, and observes what syscall index that child uses. That gives a complete and correct custom table which can be stored in a file known to further invocations of strace.
I am sure this method must have been considered, as it is not anything particularly ingenious. So there must be something wrong with it. What is wrong??