ptrace.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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, write to the Free
  15. Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
  16. Boston, MA 02110-1301, USA. */
  17. #ifndef _SYS_PTRACE_H
  18. #define _SYS_PTRACE_H 1
  19. #include <features.h>
  20. /* Kludge away careless namespace pollution from the kernel. */
  21. #undef PTRACE_GETREGS
  22. #undef PTRACE_SETREGS
  23. #undef PTRACE_GETFPREGS
  24. #undef PTRACE_SETFPREGS
  25. #undef PTRACE_GETFPREGSIZE
  26. __BEGIN_DECLS
  27. /* Type of the REQUEST argument to `ptrace.' */
  28. enum __ptrace_request
  29. {
  30. /* Indicate that the process making this request should be traced.
  31. All signals received by this process can be intercepted by its
  32. parent, and its parent can use the other `ptrace' requests. */
  33. PTRACE_TRACEME = 0,
  34. #define PT_TRACE_ME PTRACE_TRACEME
  35. /* Return the word in the process's text space at address ADDR. */
  36. PTRACE_PEEKTEXT = 1,
  37. #define PT_READ_I PTRACE_PEEKTEXT
  38. /* Return the word in the process's data space at address ADDR. */
  39. PTRACE_PEEKDATA = 2,
  40. #define PT_READ_D PTRACE_PEEKDATA
  41. /* Return the word in the process's user area at offset ADDR. */
  42. PTRACE_PEEKUSER = 3,
  43. #define PT_READ_U PTRACE_PEEKUSER
  44. /* Write the word DATA into the process's text space at address ADDR. */
  45. PTRACE_POKETEXT = 4,
  46. #define PT_WRITE_I PTRACE_POKETEXT
  47. /* Write the word DATA into the process's data space at address ADDR. */
  48. PTRACE_POKEDATA = 5,
  49. #define PT_WRITE_D PTRACE_POKEDATA
  50. /* Write the word DATA into the process's user area at offset ADDR. */
  51. PTRACE_POKEUSER = 6,
  52. #define PT_WRITE_U PTRACE_POKEUSER
  53. /* Continue the process. */
  54. PTRACE_CONT = 7,
  55. #define PT_CONTINUE PTRACE_CONT
  56. /* Kill the process. */
  57. PTRACE_KILL = 8,
  58. #define PT_KILL PTRACE_KILL
  59. /* Single step the process.
  60. This is not supported on all machines. */
  61. PTRACE_SINGLESTEP = 9,
  62. #define PT_STEP PTRACE_SINGLESTEP
  63. /* Get all general purpose registers used by a processes.
  64. This is not supported on all machines. */
  65. PTRACE_GETREGS = 12,
  66. #define PT_GETREGS PTRACE_GETREGS
  67. /* Set all general purpose registers used by a processes.
  68. This is not supported on all machines. */
  69. PTRACE_SETREGS = 13,
  70. #define PT_SETREGS PTRACE_SETREGS
  71. /* Get all floating point registers used by a processes.
  72. This is not supported on all machines. */
  73. PTRACE_GETFPREGS = 14,
  74. #define PT_GETFPREGS PTRACE_GETFPREGS
  75. /* Set all floating point registers used by a processes.
  76. This is not supported on all machines. */
  77. PTRACE_SETFPREGS = 15,
  78. #define PT_SETFPREGS PTRACE_SETFPREGS
  79. /* Attach to a process that is already running. */
  80. PTRACE_ATTACH = 16,
  81. #define PT_ATTACH PTRACE_ATTACH
  82. /* Detach from a process attached to with PTRACE_ATTACH. */
  83. PTRACE_DETACH = 17,
  84. #define PT_DETACH PTRACE_DETACH
  85. /* Get size required for the buffer holding the floating point registers.
  86. This is not supported on all machines. */
  87. PTRACE_GETFPREGSIZE = 18,
  88. #define PT_GETFPREGSIZE PTRACE_GETFPREGSIZE
  89. /* Continue and stop at the next (return from) syscall. */
  90. PTRACE_SYSCALL = 24
  91. #define PT_SYSCALL PTRACE_SYSCALL
  92. };
  93. /* Options set using PTRACE_SETOPTIONS. */
  94. enum __ptrace_setoptions {
  95. PTRACE_O_TRACESYSGOOD = 0x00000001,
  96. PTRACE_O_TRACEFORK = 0x00000002,
  97. PTRACE_O_TRACEVFORK = 0x00000004,
  98. PTRACE_O_TRACECLONE = 0x00000008,
  99. PTRACE_O_TRACEEXEC = 0x00000010,
  100. PTRACE_O_TRACEVFORKDONE = 0x00000020,
  101. PTRACE_O_TRACEEXIT = 0x00000040,
  102. PTRACE_O_MASK = 0x0000007f
  103. };
  104. /* Wait extended result codes for the above trace options. */
  105. enum __ptrace_eventcodes {
  106. PTRACE_EVENT_FORK = 1,
  107. PTRACE_EVENT_VFORK = 2,
  108. PTRACE_EVENT_CLONE = 3,
  109. PTRACE_EVENT_EXEC = 4,
  110. PTRACE_EVENT_VFORK_DONE = 5,
  111. PTRACE_EVENT_EXIT = 6
  112. };
  113. /* Perform process tracing functions. REQUEST is one of the values
  114. above, and determines the action to be taken.
  115. For all requests except PTRACE_TRACEME, PID specifies the process to be
  116. traced.
  117. PID and the other arguments described above for the various requests should
  118. appear (those that are used for the particular request) as:
  119. pid_t PID, void *ADDR, int DATA, void *ADDR2
  120. after REQUEST. */
  121. extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
  122. __END_DECLS
  123. #endif /* _SYS_PTRACE_H */