This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Compile error: 'PTRACE_GETREGS' undeclared (first use in this function) by arm64-sdk
- From: Cui Bixuan <cuibixuan at huawei dot com>
- To: Arnd Bergmann <arnd at arndb dot de>
- Cc: <libc-alpha at sourceware dot org>, linya <linya1 at huawei dot com>, Li Jinyue <lijinyue at huawei dot com>, <zhanyongming at huawei dot com>
- Date: Wed, 18 Nov 2015 17:31:11 +0800
- Subject: Re: Compile error: 'PTRACE_GETREGS' undeclared (first use in this function) by arm64-sdk
- Authentication-results: sourceware.org; auth=none
- References: <564C2450 dot 8010105 at huawei dot com> <9999504 dot 0NoXZdxpIm at wuerfel>
On 2015/11/18 16:21, Arnd Bergmann wrote:
> 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.
>
Thanks for you help.
Cui Bixuan
> Arnd
>
>