Update AArch64 strace to also support tracing 32-bit ARM binaries
Denys Vlasenko
dvlasenk at redhat.com
Tue Feb 5 16:02:34 UTC 2013
On 11/10/2012 12:24 PM, Steve McIntyre wrote:
> @@ -916,6 +923,29 @@ get_scno(struct tcb *tcp)
> if (upeek(tcp, PT_R15, &scno) < 0)
> return -1;
> }
> +#elif defined(AARCH64)
> + struct iovec io;
> + char buf[sizeof(aarch64_regs)];
> + io.iov_base = &buf;
> + io.iov_len = sizeof(aarch64_regs);
> + if (ptrace(PTRACE_GETREGSET, tcp->pid, NT_PRSTATUS, (void *)&io) == -1)
> + return -1;
> + switch (io.iov_len) {
> + case sizeof(aarch64_regs):
> + /* We are in 64-bit mode */
> + memcpy(&aarch64_regs, buf, sizeof(aarch64_regs));
> + scno = aarch64_regs.regs[8];
> + update_personality(tcp, 1);
> + break;
> + case sizeof(regs):
> + /* We are in 32-bit mode */
> + memcpy(®s, buf, sizeof(regs));
> + scno = regs.uregs[7];
> + update_personality(tcp, 0);
> + break;
> + default:
> + return -1;
> + }
> #elif defined(ARM)
> /* Read complete register set in one go. */
> if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1)
You check and set personality in get_scno(). Ok.
> @@ -1655,16 +1681,31 @@ get_syscall_result(struct tcb *tcp)
> return -1;
> if (upeek(tcp, PT_R10, &r10) < 0)
> return -1;
> -#elif defined(ARM)
> - /* Read complete register set in one go. */
> - if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1)
> - return -1;
> #elif defined(AARCH64)
> struct iovec io;
> - io.iov_base = ®s;
> - io.iov_len = sizeof(regs);
> + char buf[sizeof(aarch64_regs)];
> + io.iov_base = &buf;
> + io.iov_len = sizeof(aarch64_regs);
> if (ptrace(PTRACE_GETREGSET, tcp->pid, NT_PRSTATUS, (void *)&io) == -1)
> return -1;
> + switch (io.iov_len) {
> + case sizeof(aarch64_regs):
> + /* We are in 64-bit mode */
> + memcpy(&aarch64_regs, buf, sizeof(aarch64_regs));
> + update_personality(tcp, 1);
> + break;
> + case sizeof(regs):
> + /* We are in 32-bit mode */
> + memcpy(®s, buf, sizeof(regs));
> + update_personality(tcp, 0);
> + break;
> + default:
> + return -1;
> + }
No other architecture calls update_personality() on syscall exit
(get_syscall_result() is called, naturally, only on exit).
I think these update_personality() calls can be safely removed.
--
vda
More information about the Strace-devel
mailing list