Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* 
0003  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
0004  */
0005 
0006 #ifndef __PTRACE_USER_H__
0007 #define __PTRACE_USER_H__
0008 
0009 #include <sys/ptrace.h>
0010 #include <sysdep/ptrace_user.h>
0011 
0012 extern int ptrace_getregs(long pid, unsigned long *regs_out);
0013 extern int ptrace_setregs(long pid, unsigned long *regs_in);
0014 
0015 /* syscall emulation path in ptrace */
0016 
0017 #ifndef PTRACE_SYSEMU
0018 #define PTRACE_SYSEMU 31
0019 #endif
0020 #ifndef PTRACE_SYSEMU_SINGLESTEP
0021 #define PTRACE_SYSEMU_SINGLESTEP 32
0022 #endif
0023 
0024 /* On architectures, that started to support PTRACE_O_TRACESYSGOOD
0025  * in linux 2.4, there are two different definitions of
0026  * PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200.
0027  * For binary compatibility, 2.6 also supports the old "21", named
0028  * PTRACE_OLDSETOPTION. On these architectures, UML always must use
0029  * "21", to ensure the kernel runs on 2.4 and 2.6 host without
0030  * recompilation. So, we use PTRACE_OLDSETOPTIONS in UML.
0031  * We also want to be able to build the kernel on 2.4, which doesn't
0032  * have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare
0033  * PTRACE_OLDSETOPTIONS to be the same as PTRACE_SETOPTIONS.
0034  *
0035  * On architectures, that start to support PTRACE_O_TRACESYSGOOD on
0036  * linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't
0037  * supported by the host kernel. In that case, our trick lets us use
0038  * the new 0x4200 with the name PTRACE_OLDSETOPTIONS.
0039  */
0040 #ifndef PTRACE_OLDSETOPTIONS
0041 #define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS
0042 #endif
0043 
0044 void set_using_sysemu(int value);
0045 int get_using_sysemu(void);
0046 extern int sysemu_supported;
0047 
0048 #define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \
0049     (((int[3][3] ) { \
0050         { PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \
0051         { PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \
0052         { PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, \
0053           PTRACE_SYSEMU_SINGLESTEP } }) \
0054         [sysemu_mode][singlestep_mode])
0055 
0056 #endif