gdb/gdb_ptrace.h - gdb

Macros defined

Source code

  1. /* Portable <sys/ptrace.h>

  2.    Copyright (C) 2004-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program 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
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef GDB_PTRACE_H
  15. #define GDB_PTRACE_H

  16. /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
  17.    the PT_* symbolic constants for the ptrace(2) request numbers.  The
  18.    ptrace(2) prototype was added later to the same header on BSD.
  19.    SunOS and GNU/Linux have slightly different symbolic names for the
  20.    constants that start with PTRACE_*.  System V still doesn't have
  21.    (and probably never will have) a <sys/ptrace.h> with symbolic
  22.    constants; the ptrace(2) prototype can be found in <unistd.h>.
  23.    Fortunately all systems use the same numerical constants for the
  24.    common ptrace requests.  */

  25. #ifdef HAVE_PTRACE_H
  26. # include <ptrace.h>
  27. #elif defined(HAVE_SYS_PTRACE_H)
  28. # include <sys/ptrace.h>
  29. #endif

  30. /* No need to include <unistd.h> since it's already included by
  31.    "defs.h".  */

  32. #ifndef PT_TRACE_ME
  33. # define PT_TRACE_ME        0
  34. #endif

  35. #ifndef PT_READ_I
  36. # define PT_READ_I        1        /* Read word in child's I space.  */
  37. #endif

  38. #ifndef PT_READ_D
  39. # define PT_READ_D        2        /* Read word in child's D space.  */
  40. #endif

  41. #ifndef PT_READ_U
  42. # define PT_READ_U        3        /* Read word in child's U space.  */
  43. #endif

  44. #ifndef PT_WRITE_I
  45. # define PT_WRITE_I        4        /* Write word in child's I space.  */
  46. #endif

  47. #ifndef PT_WRITE_D
  48. # define PT_WRITE_D        5        /* Write word in child's D space.  */
  49. #endif

  50. #ifndef PT_WRITE_U
  51. # define PT_WRITE_U        6        /* Write word in child's U space.  */
  52. #endif

  53. /* HP-UX doesn't define PT_CONTINUE and PT_STEP.  Instead of those two
  54.    ptrace requests, it has PT_CONTIN, PT_CONTIN1, PT_SINGLE and
  55.    PT_SINGLE1.  PT_CONTIN1 and PT_SINGLE1 preserve pending signals,
  56.    which apparently is what is wanted by the HP-UX native code.  */

  57. #ifndef PT_CONTINUE
  58. # ifdef PT_CONTIN1
  59. #  define PT_CONTINUE        PT_CONTIN1
  60. # else
  61. #  define PT_CONTINUE        7        /* Continue the child.  */
  62. # endif
  63. #endif

  64. #ifndef PT_KILL
  65. # define PT_KILL        8        /* Kill the child process.  */
  66. #endif

  67. #ifndef PT_STEP
  68. # ifdef PT_SINGLE1
  69. #  define PT_STEP        PT_SINGLE1
  70. # else
  71. #  define PT_STEP        9        /* Single step the child.   */
  72. # endif
  73. #endif

  74. /* Not all systems support attaching and detaching.   */

  75. #ifndef PT_ATTACH
  76. # ifdef PTRACE_ATTACH
  77. #  define PT_ATTACH PTRACE_ATTACH
  78. # endif
  79. #endif

  80. #ifndef PT_DETACH
  81. # ifdef PTRACE_DETACH
  82. #  define PT_DETACH PTRACE_DETACH
  83. # endif
  84. #endif

  85. /* For systems such as HP/UX that do not provide PT_SYSCALL, define it
  86.    here as an alias for PT_CONTINUE.  This is what the PT_SYSCALL
  87.    request is expected to do, in addition to stopping when entering/
  88.    exiting a system call.  Chances are, if the system supports system
  89.    call tracing, enabling this feature is probably done separately;
  90.    and there is probably no special request that we would be required
  91.    to use when resuming the execution of our program.  */
  92. #ifndef PT_SYSCALL
  93. # ifdef PTRACE_SYSCALL
  94. #  define PT_SYSCALL PTRACE_SYSCALL
  95. #else
  96. #  define PT_SYSCALL PT_CONTINUE
  97. # endif
  98. #endif

  99. /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
  100.    or whatever it's called these days, don't provide a prototype for
  101.    ptrace.  Provide one to silence compiler warnings.  */

  102. #ifndef HAVE_DECL_PTRACE
  103. extern PTRACE_TYPE_RET ptrace();
  104. #endif

  105. /* Some systems, at least AIX and HP-UX have a ptrace with five
  106.    arguments.  Since we never use the fifth argument, define a ptrace
  107.    macro that calls the real ptrace with the last argument set to
  108.    zero.  */

  109. #ifdef PTRACE_TYPE_ARG5
  110. # ifdef HAVE_PTRACE64
  111. #  define ptrace(request, pid, addr, data) \
  112.           ptrace64 (request, pid, addr, data, 0)
  113. #  undef PTRACE_TYPE_ARG3
  114. #  define PTRACE_TYPE_ARG3 long long
  115. # else
  116. #  define ptrace(request, pid, addr, data) \
  117.           ptrace (request, pid, addr, data, 0)
  118. # endif
  119. #endif

  120. #endif /* gdb_ptrace.h */