1 /*
2  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5 
6 #ifndef __PTRACE_USER_H__
7 #define __PTRACE_USER_H__
8 
9 #include "sysdep/ptrace_user.h"
10 
11 extern int ptrace_getregs(long pid, unsigned long *regs_out);
12 extern int ptrace_setregs(long pid, unsigned long *regs_in);
13 
14 /* syscall emulation path in ptrace */
15 
16 #ifndef PTRACE_SYSEMU
17 #define PTRACE_SYSEMU 31
18 #endif
19 #ifndef PTRACE_SYSEMU_SINGLESTEP
20 #define PTRACE_SYSEMU_SINGLESTEP 32
21 #endif
22 
23 /* On architectures, that started to support PTRACE_O_TRACESYSGOOD
24  * in linux 2.4, there are two different definitions of
25  * PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200.
26  * For binary compatibility, 2.6 also supports the old "21", named
27  * PTRACE_OLDSETOPTION. On these architectures, UML always must use
28  * "21", to ensure the kernel runs on 2.4 and 2.6 host without
29  * recompilation. So, we use PTRACE_OLDSETOPTIONS in UML.
30  * We also want to be able to build the kernel on 2.4, which doesn't
31  * have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare
32  * PTRACE_OLDSETOPTIONS to be the same as PTRACE_SETOPTIONS.
33  *
34  * On architectures, that start to support PTRACE_O_TRACESYSGOOD on
35  * linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't
36  * supported by the host kernel. In that case, our trick lets us use
37  * the new 0x4200 with the name PTRACE_OLDSETOPTIONS.
38  */
39 #ifndef PTRACE_OLDSETOPTIONS
40 #define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS
41 #endif
42 
43 void set_using_sysemu(int value);
44 int get_using_sysemu(void);
45 extern int sysemu_supported;
46 
47 #define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \
48 	(((int[3][3] ) { \
49 		{ PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \
50 		{ PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \
51 		{ PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, \
52 		  PTRACE_SYSEMU_SINGLESTEP } }) \
53 		[sysemu_mode][singlestep_mode])
54 
55 #endif
56