(root)/
strace-6.5/
src/
ptrace.h
       1  /*
       2   * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
       3   * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
       4   * Copyright (c) 1993-1996 Rick Sladkey <jrs@world.std.com>
       5   * Copyright (c) 2004 Roland McGrath <roland@redhat.com>
       6   * Copyright (c) 2010 Wang Chao <wang.chao@cn.fujitsu.com>
       7   * Copyright (c) 2011-2013 Denys Vlasenko <vda.linux@googlemail.com>
       8   * Copyright (c) 2011-2016 Dmitry V. Levin <ldv@strace.io>
       9   * Copyright (c) 2013 Ali Polatel <alip@exherbo.org>
      10   * Copyright (c) 2015 Mike Frysinger <vapier@gentoo.org>
      11   * Copyright (c) 2015-2023 The strace developers.
      12   * All rights reserved.
      13   *
      14   * SPDX-License-Identifier: LGPL-2.1-or-later
      15   */
      16  
      17  #ifndef STRACE_PTRACE_H
      18  # define STRACE_PTRACE_H
      19  
      20  # include <stdint.h>
      21  # include <sys/ptrace.h>
      22  
      23  # ifdef HAVE_STRUCT_IA64_FPREG
      24  #  define ia64_fpreg XXX_ia64_fpreg
      25  # endif
      26  # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
      27  #  define pt_all_user_regs XXX_pt_all_user_regs
      28  # endif
      29  # ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
      30  #  define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
      31  # endif
      32  
      33  # include <linux/ptrace.h>
      34  
      35  # ifdef HAVE_STRUCT_IA64_FPREG
      36  #  undef ia64_fpreg
      37  # endif
      38  # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
      39  #  undef pt_all_user_regs
      40  # endif
      41  # ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
      42  #  undef ptrace_peeksiginfo_args
      43  # endif
      44  
      45  # if defined(SPARC) || defined(SPARC64)
      46  /*
      47   * SPARC has a different PTRACE_DETACH value correctly defined in sys/ptrace.h,
      48   * but linux/ptrace.h clobbers it with the standard one.  PTRACE_SUNDETACH is
      49   * also defined to the correct value by sys/ptrace.h, so use that instead.
      50   */
      51  #  undef PTRACE_DETACH
      52  #  define PTRACE_DETACH PTRACE_SUNDETACH
      53  # endif
      54  
      55  # ifndef PTRACE_EVENT_FORK
      56  #  define PTRACE_EVENT_FORK	1
      57  # endif
      58  # ifndef PTRACE_EVENT_VFORK
      59  #  define PTRACE_EVENT_VFORK	2
      60  # endif
      61  # ifndef PTRACE_EVENT_CLONE
      62  #  define PTRACE_EVENT_CLONE	3
      63  # endif
      64  # ifndef PTRACE_EVENT_EXEC
      65  #  define PTRACE_EVENT_EXEC	4
      66  # endif
      67  # ifndef PTRACE_EVENT_VFORK_DONE
      68  #  define PTRACE_EVENT_VFORK_DONE	5
      69  # endif
      70  # ifndef PTRACE_EVENT_EXIT
      71  #  define PTRACE_EVENT_EXIT	6
      72  # endif
      73  # ifndef PTRACE_EVENT_SECCOMP
      74  #  define PTRACE_EVENT_SECCOMP	7
      75  # endif
      76  # ifdef PTRACE_EVENT_STOP
      77  /* Linux 3.1 - 3.3 releases had a broken value.  It was fixed in 3.4.  */
      78  #  if PTRACE_EVENT_STOP == 7
      79  #   undef PTRACE_EVENT_STOP
      80  #  endif
      81  # endif
      82  # ifndef PTRACE_EVENT_STOP
      83  #  define PTRACE_EVENT_STOP	128
      84  # endif
      85  
      86  # ifndef PTRACE_O_TRACESYSGOOD
      87  #  define PTRACE_O_TRACESYSGOOD	1
      88  # endif
      89  # ifndef PTRACE_O_TRACEFORK
      90  #  define PTRACE_O_TRACEFORK	(1 << PTRACE_EVENT_FORK)
      91  # endif
      92  # ifndef PTRACE_O_TRACEVFORK
      93  #  define PTRACE_O_TRACEVFORK	(1 << PTRACE_EVENT_VFORK)
      94  # endif
      95  # ifndef PTRACE_O_TRACECLONE
      96  #  define PTRACE_O_TRACECLONE	(1 << PTRACE_EVENT_CLONE)
      97  # endif
      98  # ifndef PTRACE_O_TRACEEXEC
      99  #  define PTRACE_O_TRACEEXEC	(1 << PTRACE_EVENT_EXEC)
     100  # endif
     101  # ifndef PTRACE_O_TRACEVFORKDONE
     102  #  define PTRACE_O_TRACEVFORKDONE	(1 << PTRACE_EVENT_VFORK_DONE)
     103  # endif
     104  # ifndef PTRACE_O_TRACEEXIT
     105  #  define PTRACE_O_TRACEEXIT	(1 << PTRACE_EVENT_EXIT)
     106  # endif
     107  # ifndef PTRACE_O_TRACESECCOMP
     108  #  define PTRACE_O_TRACESECCOMP	(1 << PTRACE_EVENT_SECCOMP)
     109  # endif
     110  # ifndef PTRACE_O_EXITKILL
     111  #  define PTRACE_O_EXITKILL	(1 << 20)
     112  # endif
     113  # ifndef PTRACE_O_SUSPEND_SECCOMP
     114  #  define PTRACE_O_SUSPEND_SECCOMP	(1 << 21)
     115  # endif
     116  
     117  # ifndef PTRACE_SETOPTIONS
     118  #  define PTRACE_SETOPTIONS	0x4200
     119  # endif
     120  # ifndef PTRACE_GETEVENTMSG
     121  #  define PTRACE_GETEVENTMSG	0x4201
     122  # endif
     123  # ifndef PTRACE_GETSIGINFO
     124  #  define PTRACE_GETSIGINFO	0x4202
     125  # endif
     126  # ifndef PTRACE_SETSIGINFO
     127  #  define PTRACE_SETSIGINFO	0x4203
     128  # endif
     129  # ifndef PTRACE_GETREGSET
     130  #  define PTRACE_GETREGSET	0x4204
     131  # endif
     132  # ifndef PTRACE_SETREGSET
     133  #  define PTRACE_SETREGSET	0x4205
     134  # endif
     135  # ifndef PTRACE_SEIZE
     136  #  define PTRACE_SEIZE		0x4206
     137  # endif
     138  # ifndef PTRACE_INTERRUPT
     139  #  define PTRACE_INTERRUPT	0x4207
     140  # endif
     141  # ifndef PTRACE_LISTEN
     142  #  define PTRACE_LISTEN		0x4208
     143  # endif
     144  # ifndef PTRACE_PEEKSIGINFO
     145  #  define PTRACE_PEEKSIGINFO	0x4209
     146  # endif
     147  # ifndef PTRACE_GETSIGMASK
     148  #  define PTRACE_GETSIGMASK	0x420a
     149  # endif
     150  # ifndef PTRACE_SETSIGMASK
     151  #  define PTRACE_SETSIGMASK	0x420b
     152  # endif
     153  # ifndef PTRACE_SECCOMP_GET_FILTER
     154  #  define PTRACE_SECCOMP_GET_FILTER	0x420c
     155  # endif
     156  # ifndef PTRACE_SECCOMP_GET_METADATA
     157  #  define PTRACE_SECCOMP_GET_METADATA	0x420d
     158  # endif
     159  # ifndef PTRACE_GET_SYSCALL_INFO
     160  #  define PTRACE_GET_SYSCALL_INFO	0x420e
     161  #  define PTRACE_SYSCALL_INFO_NONE	0
     162  #  define PTRACE_SYSCALL_INFO_ENTRY	1
     163  #  define PTRACE_SYSCALL_INFO_EXIT	2
     164  #  define PTRACE_SYSCALL_INFO_SECCOMP	3
     165  # endif
     166  # ifndef PTRACE_GET_RSEQ_CONFIGURATION
     167  #  define PTRACE_GET_RSEQ_CONFIGURATION	0x420f
     168  # endif
     169  # ifndef PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG
     170  #  define PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG	0x4210
     171  # endif
     172  # ifndef PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG
     173  #  define PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG	0x4211
     174  # endif
     175  
     176  # if defined HAVE_STRUCT_PTRACE_SYSCALL_INFO
     177  typedef struct ptrace_syscall_info struct_ptrace_syscall_info;
     178  # elif defined HAVE_STRUCT___PTRACE_SYSCALL_INFO
     179  typedef struct __ptrace_syscall_info struct_ptrace_syscall_info;
     180  # else
     181  struct ptrace_syscall_info {
     182  	uint8_t op;
     183  	uint8_t pad[3];
     184  	uint32_t arch;
     185  	uint64_t instruction_pointer;
     186  	uint64_t stack_pointer;
     187  	union {
     188  		struct {
     189  			uint64_t nr;
     190  			uint64_t args[6];
     191  		} entry;
     192  		struct {
     193  			int64_t rval;
     194  			uint8_t is_error;
     195  		} exit;
     196  		struct {
     197  			uint64_t nr;
     198  			uint64_t args[6];
     199  			uint32_t ret_data;
     200  		} seccomp;
     201  	};
     202  };
     203  typedef struct ptrace_syscall_info struct_ptrace_syscall_info;
     204  # endif
     205  
     206  # if !HAVE_DECL_PTRACE_PEEKUSER
     207  #  define PTRACE_PEEKUSER PTRACE_PEEKUSR
     208  # endif
     209  # if !HAVE_DECL_PTRACE_POKEUSER
     210  #  define PTRACE_POKEUSER PTRACE_POKEUSR
     211  # endif
     212  
     213  #endif /* !STRACE_PTRACE_H */