ptrace.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* `ptrace' debugger support interface. Linux version.
  2. Copyright (C) 1996-1999,2000,2006,2007 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _SYS_PTRACE_H
  17. #define _SYS_PTRACE_H 1
  18. #include <features.h>
  19. __BEGIN_DECLS
  20. /* Type of the REQUEST argument to `ptrace.' */
  21. enum __ptrace_request
  22. {
  23. /* Indicate that the process making this request should be traced.
  24. All signals received by this process can be intercepted by its
  25. parent, and its parent can use the other `ptrace' requests. */
  26. PTRACE_TRACEME = 0,
  27. #define PT_TRACE_ME PTRACE_TRACEME
  28. /* Return the word in the process's text space at address ADDR. */
  29. PTRACE_PEEKTEXT = 1,
  30. #define PT_READ_I PTRACE_PEEKTEXT
  31. /* Return the word in the process's data space at address ADDR. */
  32. PTRACE_PEEKDATA = 2,
  33. #define PT_READ_D PTRACE_PEEKDATA
  34. /* Return the word in the process's user area at offset ADDR. */
  35. PTRACE_PEEKUSER = 3,
  36. #define PT_READ_U PTRACE_PEEKUSER
  37. /* Write the word DATA into the process's text space at address ADDR. */
  38. PTRACE_POKETEXT = 4,
  39. #define PT_WRITE_I PTRACE_POKETEXT
  40. /* Write the word DATA into the process's data space at address ADDR. */
  41. PTRACE_POKEDATA = 5,
  42. #define PT_WRITE_D PTRACE_POKEDATA
  43. /* Write the word DATA into the process's user area at offset ADDR. */
  44. PTRACE_POKEUSER = 6,
  45. #define PT_WRITE_U PTRACE_POKEUSER
  46. /* Continue the process. */
  47. PTRACE_CONT = 7,
  48. #define PT_CONTINUE PTRACE_CONT
  49. /* Kill the process. */
  50. PTRACE_KILL = 8,
  51. #define PT_KILL PTRACE_KILL
  52. /* Single step the process.
  53. This is not supported on all machines. */
  54. PTRACE_SINGLESTEP = 9,
  55. #define PT_STEP PTRACE_SINGLESTEP
  56. /* Get all general purpose registers used by a processes.
  57. This is not supported on all machines. */
  58. PTRACE_GETREGS = 12,
  59. #define PT_GETREGS PTRACE_GETREGS
  60. /* Set all general purpose registers used by a processes.
  61. This is not supported on all machines. */
  62. PTRACE_SETREGS = 13,
  63. #define PT_SETREGS PTRACE_SETREGS
  64. /* Get all floating point registers used by a processes.
  65. This is not supported on all machines. */
  66. PTRACE_GETFPREGS = 14,
  67. #define PT_GETFPREGS PTRACE_GETFPREGS
  68. /* Set all floating point registers used by a processes.
  69. This is not supported on all machines. */
  70. PTRACE_SETFPREGS = 15,
  71. #define PT_SETFPREGS PTRACE_SETFPREGS
  72. /* Attach to a process that is already running. */
  73. PTRACE_ATTACH = 16,
  74. #define PT_ATTACH PTRACE_ATTACH
  75. /* Detach from a process attached to with PTRACE_ATTACH. */
  76. PTRACE_DETACH = 17,
  77. #define PT_DETACH PTRACE_DETACH
  78. /* Get all extended floating point registers used by a processes.
  79. This is not supported on all machines. */
  80. PTRACE_GETFPXREGS = 18,
  81. #define PT_GETFPXREGS PTRACE_GETFPXREGS
  82. /* Set all extended floating point registers used by a processes.
  83. This is not supported on all machines. */
  84. PTRACE_SETFPXREGS = 19,
  85. #define PT_SETFPXREGS PTRACE_SETFPXREGS
  86. /* Continue and stop at the next (return from) syscall. */
  87. PTRACE_SYSCALL = 24,
  88. #define PT_SYSCALL PTRACE_SYSCALL
  89. /* Obtain the load map of the main program or the interpreter of the
  90. ptraced process, depending on whether the addr argument is
  91. (void*)0 or (void*)1, respectively. */
  92. PTRACE_GETDSBT = 31,
  93. #define PT_GETDSBT PTRACE_GETDSBT
  94. /* Set ptrace filter options. */
  95. PTRACE_SETOPTIONS = 0x4200,
  96. #define PT_SETOPTIONS PTRACE_SETOPTIONS
  97. /* Get last ptrace message. */
  98. PTRACE_GETEVENTMSG = 0x4201,
  99. #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
  100. /* Get siginfo for process. */
  101. PTRACE_GETSIGINFO = 0x4202,
  102. #define PT_GETSIGINFO PTRACE_GETSIGINFO
  103. /* Set new siginfo for process. */
  104. PTRACE_SETSIGINFO = 0x4203
  105. #define PT_SETSIGINFO PTRACE_SETSIGINFO
  106. };
  107. #define PTRACE_GETDSBT_EXEC ((void*)0) /* [addr] request the executable loadmap */
  108. #define PTRACE_GETDSBT_INTERP ((void*)1) /* [addr] request the interpreter loadmap */
  109. /* Options set using PTRACE_SETOPTIONS. */
  110. enum __ptrace_setoptions {
  111. PTRACE_O_TRACESYSGOOD = 0x00000001,
  112. PTRACE_O_TRACEFORK = 0x00000002,
  113. PTRACE_O_TRACEVFORK = 0x00000004,
  114. PTRACE_O_TRACECLONE = 0x00000008,
  115. PTRACE_O_TRACEEXEC = 0x00000010,
  116. PTRACE_O_TRACEVFORKDONE = 0x00000020,
  117. PTRACE_O_TRACEEXIT = 0x00000040,
  118. PTRACE_O_MASK = 0x0000007f
  119. };
  120. /* Wait extended result codes for the above trace options. */
  121. enum __ptrace_eventcodes {
  122. PTRACE_EVENT_FORK = 1,
  123. PTRACE_EVENT_VFORK = 2,
  124. PTRACE_EVENT_CLONE = 3,
  125. PTRACE_EVENT_EXEC = 4,
  126. PTRACE_EVENT_VFORK_DONE = 5,
  127. PTRACE_EVENT_EXIT = 6
  128. };
  129. /* Perform process tracing functions. REQUEST is one of the values
  130. above, and determines the action to be taken.
  131. For all requests except PTRACE_TRACEME, PID specifies the process to be
  132. traced.
  133. PID and the other arguments described above for the various requests should
  134. appear (those that are used for the particular request) as:
  135. pid_t PID, void *ADDR, int DATA, void *ADDR2
  136. after REQUEST. */
  137. extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
  138. __END_DECLS
  139. #endif /* _SYS_PTRACE_H */