ptrace.h 4.8 KB

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