Compile error: 'PTRACE_GETREGS' undeclared (first use in this function) by arm64-sdk
Arnd Bergmann
arnd@arndb.de
Wed Nov 18 08:21:00 GMT 2015
On Wednesday 18 November 2015 15:10:08 Cui Bixuan wrote:
> Hi,
> I want to use ptrace in arm64, and there is a compile problem:
>
> # aarch64-linux-gnu-gcc ptrace.c -o ptrace
> ptrace.c: In function 'main':
> ptrace.c:48:29: error: 'PTRACE_GETREGS' undeclared (first use in this function)
> ptrace_ret = ptrace(PTRACE_GETREGS, child, NULL, ®s);
> ^
> If the glibc does not support 'PTRACE_GETREGS'?
>
>
> but I find:
>
> /* Get register content. */
> PTRACE_GETREGSET = 0x4204,
> #define PTRACE_GETREGSET PTRACE_GETREGSET
>
> in eglibc-2.19/libc/ports/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h.
> Then I don't know why
>
>
> And I know 'regs' in ptrace(PTRACE_GETREGS, child, NULL, ®s) can define:
> 'struct user regs' in arm or powerpc;
> 'struct user_fpregs_struct regs' in X86_64 or i386;
>
> but I can't find the struct in eglibc-2.19/libc/ports/sysdeps/unix/sysv/linux/aarch64/sys/user.h
> What should I do in arm64 if I want to use it?
This is really a kernel question, not glibc. Anyway, on new architectures like
arm64, you need to use PTRACE_GETREGSET instead of PTRACE_GETREGS.
To get the normal registers, use REGSET_GPR, which gives you a struct user_pt_regs,
or use REGSET_FPR, REGSET_TLS, REGSET_HW_BREAK, REGSET_HW_WATCH or REGSET_SYSTEM_CALL
to get the other registers and related things.
Arnd
More information about the Libc-alpha
mailing list