ptrace_user.h 1.9 KB

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