ptrace.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* $OpenBSD: ptrace.h,v 1.14 2012/04/13 16:37:50 kettenis Exp $ */
  2. /* $NetBSD: ptrace.h,v 1.21 1996/02/09 18:25:26 christos Exp $ */
  3. /*-
  4. * Copyright (c) 1984, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the University nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * @(#)ptrace.h 8.2 (Berkeley) 1/4/94
  32. */
  33. #ifndef _SYS_PTRACE_H_
  34. #define _SYS_PTRACE_H_
  35. #define PT_TRACE_ME 0 /* child declares it's being traced */
  36. #define PT_READ_I 1 /* read word in child's I space */
  37. #define PT_READ_D 2 /* read word in child's D space */
  38. #define PT_WRITE_I 4 /* write word in child's I space */
  39. #define PT_WRITE_D 5 /* write word in child's D space */
  40. #define PT_CONTINUE 7 /* continue the child */
  41. #define PT_KILL 8 /* kill the child process */
  42. #define PT_ATTACH 9 /* attach to running process */
  43. #define PT_DETACH 10 /* detach from running process */
  44. #define PT_IO 11 /* do I/O to/from the stopped process. */
  45. struct ptrace_io_desc {
  46. int piod_op; /* I/O operation */
  47. void *piod_offs; /* child offset */
  48. void *piod_addr; /* parent offset */
  49. size_t piod_len; /* request length */
  50. };
  51. /*
  52. * Operations in piod_op.
  53. */
  54. #define PIOD_READ_D 1 /* Read from D space */
  55. #define PIOD_WRITE_D 2 /* Write to D space */
  56. #define PIOD_READ_I 3 /* Read from I space */
  57. #define PIOD_WRITE_I 4 /* Write to I space */
  58. #define PIOD_READ_AUXV 5 /* Read from aux array */
  59. #define PT_SET_EVENT_MASK 12
  60. #define PT_GET_EVENT_MASK 13
  61. typedef struct ptrace_event {
  62. int pe_set_event;
  63. } ptrace_event_t;
  64. #define PTRACE_FORK 0x0002 /* Report forks */
  65. #define PT_GET_PROCESS_STATE 14
  66. typedef struct ptrace_state {
  67. int pe_report_event;
  68. pid_t pe_other_pid;
  69. pid_t pe_tid;
  70. } ptrace_state_t;
  71. #define PT_GET_THREAD_FIRST 15
  72. #define PT_GET_THREAD_NEXT 16
  73. struct ptrace_thread_state {
  74. pid_t pts_tid;
  75. };
  76. #define PT_FIRSTMACH 32 /* for machine-specific requests */
  77. #include <machine/ptrace.h> /* machine-specific requests, if any */
  78. #ifdef _KERNEL
  79. /*
  80. * There is a bunch of PT_ requests that are machine dependent, but not
  81. * optional. Check if they were defined by MD code here.
  82. */
  83. #if !defined(PT_GETREGS) || !defined(PT_SETREGS)
  84. #error Machine dependent ptrace not complete.
  85. #endif
  86. struct reg;
  87. #if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
  88. struct fpreg;
  89. #endif
  90. void proc_reparent(struct process *child, struct process *newparent);
  91. #ifdef PT_GETFPREGS
  92. int process_read_fpregs(struct proc *p, struct fpreg *regs);
  93. #endif
  94. int process_read_regs(struct proc *p, struct reg *regs);
  95. int process_set_pc(struct proc *p, caddr_t addr);
  96. int process_sstep(struct proc *p, int sstep);
  97. #ifdef PT_SETFPREGS
  98. int process_write_fpregs(struct proc *p, struct fpreg *regs);
  99. #endif
  100. int process_write_regs(struct proc *p, struct reg *regs);
  101. int process_checkioperm(struct proc *, struct process *);
  102. int process_domem(struct proc *, struct proc *, struct uio *, int);
  103. #ifndef FIX_SSTEP
  104. #define FIX_SSTEP(p)
  105. #endif
  106. #else /* !_KERNEL */
  107. #include <sys/cdefs.h>
  108. __BEGIN_DECLS
  109. int ptrace(int _request, pid_t _pid, caddr_t _addr, int _data);
  110. __END_DECLS
  111. #endif /* !_KERNEL */
  112. #endif /* !_SYS_PTRACE_H_ */