powerpc: Undefine Linux ptrace macros that conflict with __ptrace_request

Message ID 20180213140133.2229-1-tuliom@linux.vnet.ibm.com
State New
Headers show
Series
  • powerpc: Undefine Linux ptrace macros that conflict with __ptrace_request
Related show

Commit Message

Tulio Magno Quites Machado Filho Feb. 13, 2018, 2:01 p.m.
Linux ptrace headers define macros whose tokens conflict with the
constants of enum __ptrace_request causing build errors when
asm/ptrace.h or linux/ptrace.h are included before sys/ptrace.h.

2018-02-13  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Undefine Linux
	macros used in __ptrace_request.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
---
 sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h | 44 ++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Dmitry V. Levin Feb. 13, 2018, 4:09 p.m. | #1
On Tue, Feb 13, 2018 at 12:01:33PM -0200, Tulio Magno Quites Machado Filho wrote:
> Linux ptrace headers define macros whose tokens conflict with the
> constants of enum __ptrace_request causing build errors when
> asm/ptrace.h or linux/ptrace.h are included before sys/ptrace.h.
> 
> 2018-02-13  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
> 
> 	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Undefine Linux
> 	macros used in __ptrace_request.
> 
> Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
> ---
>  sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h | 44 ++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h b/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
> index 75567b2..a8af6f7 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
> @@ -24,6 +24,50 @@
>  
>  __BEGIN_DECLS
>  
> +#if defined _LINUX_PTRACE_H || defined _ASM_POWERPC_PTRACE_H
> +/* Do not let Linux headers macros interfere with enum __ptrace_request.  */
> +# undef PTRACE_TRACEME
> +# undef PTRACE_PEEKTEXT
> +# undef PTRACE_PEEKDATA
> +# undef PTRACE_PEEKUSER
> +# undef PTRACE_POKETEXT
> +# undef PTRACE_POKEDATA
> +# undef PTRACE_POKEUSER
> +# undef PTRACE_CONT
> +# undef PTRACE_KILL
> +# undef PTRACE_SINGLESTEP
> +# undef PTRACE_GETREGS
> +# undef PTRACE_SETREGS
> +# undef PTRACE_GETFPREGS
> +# undef PTRACE_SETFPREGS
> +# undef PTRACE_ATTACH
> +# undef PTRACE_DETACH
> +# undef PTRACE_GETVRREGS
> +# undef PTRACE_SETVRREGS
> +# undef PTRACE_GETEVRREGS
> +# undef PTRACE_SETEVRREGS
> +# undef PTRACE_GETREGS64
> +# undef PTRACE_SETREGS64
> +# undef PTRACE_SYSCALL
> +# undef PTRACE_GET_DEBUGREG
> +# undef PTRACE_SET_DEBUGREG
> +# undef PTRACE_GETVSRREGS
> +# undef PTRACE_SETVSRREGS
> +# undef PTRACE_SETOPTIONS
> +# undef PTRACE_GETEVENTMSG
> +# undef PTRACE_GETSIGINFO
> +# undef PTRACE_SETSIGINFO
> +# undef PTRACE_GETREGSET
> +# undef PTRACE_SETREGSET
> +# undef PTRACE_SEIZE
> +# undef PTRACE_INTERRUPT
> +# undef PTRACE_LISTEN
> +# undef PTRACE_PEEKSIGINFO
> +# undef PTRACE_GETSIGMASK
> +# undef PTRACE_SETSIGMASK
> +# undef PTRACE_SECCOMP_GET_FILTER
> +#endif

The list looks fine, except the following:
- PTRACE_PEEKUSER and PTRACE_POKEUSER are not defined by kernel headers
  (they define PTRACE_PEEKUSR and PTRACE_POKEUSR instead) so there is no
  need to #undef them here;
- looks like PTRACE_SINGLEBLOCK should be #undef'ed here and defined
  in "sync sys/ptrace.h with Linux 4.15" patch to

  /* Execute process until next taken branch.  */
  PTRACE_SINGLEBLOCK = 256,
#define PT_STEPBLOCK PTRACE_SINGLEBLOCK
Tulio Magno Quites Machado Filho Feb. 26, 2018, 1:43 p.m. | #2
"Dmitry V. Levin" <ldv@altlinux.org> writes:

> The list looks fine, except the following:
> - PTRACE_PEEKUSER and PTRACE_POKEUSER are not defined by kernel headers
>   (they define PTRACE_PEEKUSR and PTRACE_POKEUSR instead) so there is no
>   need to #undef them here;
> - looks like PTRACE_SINGLEBLOCK should be #undef'ed here and defined
>   in "sync sys/ptrace.h with Linux 4.15" patch to
>
>   /* Execute process until next taken branch.  */
>   PTRACE_SINGLEBLOCK = 256,
> #define PT_STEPBLOCK PTRACE_SINGLEBLOCK

Fixed both issues, sorted the lines alphabetically and pushed as 398c6fddafc.

Thanks!

Patch

diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h b/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
index 75567b2..a8af6f7 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
@@ -24,6 +24,50 @@ 
 
 __BEGIN_DECLS
 
+#if defined _LINUX_PTRACE_H || defined _ASM_POWERPC_PTRACE_H
+/* Do not let Linux headers macros interfere with enum __ptrace_request.  */
+# undef PTRACE_TRACEME
+# undef PTRACE_PEEKTEXT
+# undef PTRACE_PEEKDATA
+# undef PTRACE_PEEKUSER
+# undef PTRACE_POKETEXT
+# undef PTRACE_POKEDATA
+# undef PTRACE_POKEUSER
+# undef PTRACE_CONT
+# undef PTRACE_KILL
+# undef PTRACE_SINGLESTEP
+# undef PTRACE_GETREGS
+# undef PTRACE_SETREGS
+# undef PTRACE_GETFPREGS
+# undef PTRACE_SETFPREGS
+# undef PTRACE_ATTACH
+# undef PTRACE_DETACH
+# undef PTRACE_GETVRREGS
+# undef PTRACE_SETVRREGS
+# undef PTRACE_GETEVRREGS
+# undef PTRACE_SETEVRREGS
+# undef PTRACE_GETREGS64
+# undef PTRACE_SETREGS64
+# undef PTRACE_SYSCALL
+# undef PTRACE_GET_DEBUGREG
+# undef PTRACE_SET_DEBUGREG
+# undef PTRACE_GETVSRREGS
+# undef PTRACE_SETVSRREGS
+# undef PTRACE_SETOPTIONS
+# undef PTRACE_GETEVENTMSG
+# undef PTRACE_GETSIGINFO
+# undef PTRACE_SETSIGINFO
+# undef PTRACE_GETREGSET
+# undef PTRACE_SETREGSET
+# undef PTRACE_SEIZE
+# undef PTRACE_INTERRUPT
+# undef PTRACE_LISTEN
+# undef PTRACE_PEEKSIGINFO
+# undef PTRACE_GETSIGMASK
+# undef PTRACE_SETSIGMASK
+# undef PTRACE_SECCOMP_GET_FILTER
+#endif
+
 /* Type of the REQUEST argument to `ptrace.'  */
 enum __ptrace_request
 {