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: Yao Qi <qiyaoltc at gmail dot com>
- 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: Thu, 19 Nov 2015 09:12:07 +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> <564C9458 dot 80601 at gmail dot com>
On 2015/11/18 23:08, Yao Qi wrote:
>
>
> On 18/11/15 07:10, Cui Bixuan wrote:
>> # 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'?
>
> Ptrace is an interface provided by OS to control child process for
> debugger, so PTRACE_GETREGS things should be defined in linux kernel
> headers. On aarch64, PTRACE_GETREGS is not used, as you found below,
>
>>
>>
>> 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:-(
>>
>
> PTRACE_GETREGSET is used instead of PTRACE_GETREGS.
>
>>
>> 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;
>
> They are quite arch-specific...
>
>>
>> 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?
>
> You can find them in kernel header in
> linux/arch/arm64/include/uapi/asm/ptrace.h. You can look at
> gdb/aarch64-linux-nat.c in GDB source, and see how ptrace is used there.
OK :-D
I find it! Thank you very much.
Cui Bixuan
>