Compile error: 'PTRACE_GETREGS' undeclared (first use in this function) by arm64-sdk
Cui Bixuan
cuibixuan@huawei.com
Thu Nov 19 01:12:00 GMT 2015
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
>
More information about the Libc-alpha
mailing list