gdb/nat/linux-ptrace.h - gdb

Macros defined

Source code

  1. /* Copyright (C) 2011-2015 Free Software Foundation, Inc.

  2.    This file is part of GDB.

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

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

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

  13. #ifndef COMMON_LINUX_PTRACE_H
  14. #define COMMON_LINUX_PTRACE_H

  15. struct buffer;

  16. #include <sys/ptrace.h>

  17. #ifdef __UCLIBC__
  18. #if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
  19. /* PTRACE_TEXT_ADDR and friends.  */
  20. #include <asm/ptrace.h>
  21. #define HAS_NOMMU
  22. #endif
  23. #endif

  24. #if !defined(PTRACE_TYPE_ARG3)
  25. #define PTRACE_TYPE_ARG3 void *
  26. #endif

  27. #if !defined(PTRACE_TYPE_ARG4)
  28. #define PTRACE_TYPE_ARG4 void *
  29. #endif

  30. #ifndef PTRACE_GETSIGINFO
  31. # define PTRACE_GETSIGINFO 0x4202
  32. # define PTRACE_SETSIGINFO 0x4203
  33. #endif /* PTRACE_GETSIGINF */

  34. /* If the system headers did not provide the constants, hard-code the normal
  35.    values.  */
  36. #ifndef PTRACE_EVENT_FORK

  37. #define PTRACE_SETOPTIONS        0x4200
  38. #define PTRACE_GETEVENTMSG        0x4201

  39. /* options set using PTRACE_SETOPTIONS */
  40. #define PTRACE_O_TRACESYSGOOD        0x00000001
  41. #define PTRACE_O_TRACEFORK        0x00000002
  42. #define PTRACE_O_TRACEVFORK        0x00000004
  43. #define PTRACE_O_TRACECLONE        0x00000008
  44. #define PTRACE_O_TRACEEXEC        0x00000010
  45. #define PTRACE_O_TRACEVFORKDONE        0x00000020
  46. #define PTRACE_O_TRACEEXIT        0x00000040

  47. /* Wait extended result codes for the above trace options.  */
  48. #define PTRACE_EVENT_FORK        1
  49. #define PTRACE_EVENT_VFORK        2
  50. #define PTRACE_EVENT_CLONE        3
  51. #define PTRACE_EVENT_EXEC        4
  52. #define PTRACE_EVENT_VFORK_DONE        5
  53. #define PTRACE_EVENT_EXIT        6

  54. #endif /* PTRACE_EVENT_FORK */

  55. #ifndef PTRACE_O_EXITKILL
  56. /* Only defined in Linux Kernel 3.8 or later.  */
  57. #define PTRACE_O_EXITKILL        0x00100000
  58. #endif

  59. #if (defined __bfin__ || defined __frv__ || defined __sh__) \
  60.     && !defined PTRACE_GETFDPIC
  61. #define PTRACE_GETFDPIC                31
  62. #define PTRACE_GETFDPIC_EXEC        0
  63. #define PTRACE_GETFDPIC_INTERP        1
  64. #endif

  65. /* We can't always assume that this flag is available, but all systems
  66.    with the ptrace event handlers also have __WALL, so it's safe to use
  67.    in some contexts.  */
  68. #ifndef __WALL
  69. #define __WALL          0x40000000 /* Wait for any child.  */
  70. #endif

  71. extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer);

  72. /* Find all possible reasons we could have failed to attach to PTID
  73.    and return them as a string.  ERR is the error PTRACE_ATTACH failed
  74.    with (an errno).  The result is stored in a static buffer.  This
  75.    string should be copied into a buffer by the client if the string
  76.    will not be immediately used, or if it must persist.  */
  77. extern char *linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err);

  78. extern void linux_ptrace_init_warnings (void);
  79. extern void linux_enable_event_reporting (pid_t pid, int attached);
  80. extern void linux_disable_event_reporting (pid_t pid);
  81. extern int linux_supports_tracefork (void);
  82. extern int linux_supports_traceclone (void);
  83. extern int linux_supports_tracevforkdone (void);
  84. extern int linux_supports_tracesysgood (void);
  85. extern void linux_ptrace_set_additional_flags (int);
  86. extern int linux_ptrace_get_extended_event (int wstat);
  87. extern int linux_is_extended_waitstatus (int wstat);

  88. #endif /* COMMON_LINUX_PTRACE_H */