Fix non executable stack handling when calling functions in the inferior.
[deliverable/binutils-gdb.git] / gdb / nat / linux-ptrace.h
CommitLineData
32d0add0 1/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
af96c192
YQ
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#ifndef COMMON_LINUX_PTRACE_H
19#define COMMON_LINUX_PTRACE_H
20
87b0bb13
JK
21struct buffer;
22
af96c192 23#include <sys/ptrace.h>
af96c192 24
96d7229d
LM
25#ifdef __UCLIBC__
26#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
27/* PTRACE_TEXT_ADDR and friends. */
28#include <asm/ptrace.h>
29#define HAS_NOMMU
30#endif
31#endif
32
33#if !defined(PTRACE_TYPE_ARG3)
34#define PTRACE_TYPE_ARG3 void *
35#endif
36
37#if !defined(PTRACE_TYPE_ARG4)
38#define PTRACE_TYPE_ARG4 void *
39#endif
40
af96c192
YQ
41#ifndef PTRACE_GETSIGINFO
42# define PTRACE_GETSIGINFO 0x4202
43# define PTRACE_SETSIGINFO 0x4203
44#endif /* PTRACE_GETSIGINF */
45
46/* If the system headers did not provide the constants, hard-code the normal
47 values. */
48#ifndef PTRACE_EVENT_FORK
49
50#define PTRACE_SETOPTIONS 0x4200
51#define PTRACE_GETEVENTMSG 0x4201
52
53/* options set using PTRACE_SETOPTIONS */
54#define PTRACE_O_TRACESYSGOOD 0x00000001
55#define PTRACE_O_TRACEFORK 0x00000002
56#define PTRACE_O_TRACEVFORK 0x00000004
57#define PTRACE_O_TRACECLONE 0x00000008
58#define PTRACE_O_TRACEEXEC 0x00000010
59#define PTRACE_O_TRACEVFORKDONE 0x00000020
60#define PTRACE_O_TRACEEXIT 0x00000040
61
62/* Wait extended result codes for the above trace options. */
63#define PTRACE_EVENT_FORK 1
64#define PTRACE_EVENT_VFORK 2
65#define PTRACE_EVENT_CLONE 3
66#define PTRACE_EVENT_EXEC 4
67#define PTRACE_EVENT_VFORK_DONE 5
68#define PTRACE_EVENT_EXIT 6
69
70#endif /* PTRACE_EVENT_FORK */
71
beed38b8
JB
72#ifndef PTRACE_O_EXITKILL
73/* Only defined in Linux Kernel 3.8 or later. */
74#define PTRACE_O_EXITKILL 0x00100000
75#endif
76
723b724b
MF
77#if (defined __bfin__ || defined __frv__ || defined __sh__) \
78 && !defined PTRACE_GETFDPIC
79#define PTRACE_GETFDPIC 31
80#define PTRACE_GETFDPIC_EXEC 0
81#define PTRACE_GETFDPIC_INTERP 1
82#endif
83
af96c192
YQ
84/* We can't always assume that this flag is available, but all systems
85 with the ptrace event handlers also have __WALL, so it's safe to use
86 in some contexts. */
87#ifndef __WALL
88#define __WALL 0x40000000 /* Wait for any child. */
89#endif
90
7ae1a6a6 91extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer);
8784d563
PA
92
93/* Find all possible reasons we could have failed to attach to PTID
94 and return them as a string. ERR is the error PTRACE_ATTACH failed
95 with (an errno). The result is stored in a static buffer. This
96 string should be copied into a buffer by the client if the string
97 will not be immediately used, or if it must persist. */
98extern char *linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err);
99
aa7c7447 100extern void linux_ptrace_init_warnings (void);
beed38b8 101extern void linux_enable_event_reporting (pid_t pid, int attached);
c077881a 102extern void linux_disable_event_reporting (pid_t pid);
96d7229d
LM
103extern int linux_supports_tracefork (void);
104extern int linux_supports_traceclone (void);
105extern int linux_supports_tracevforkdone (void);
106extern int linux_supports_tracesysgood (void);
8009206a 107extern void linux_ptrace_set_additional_flags (int);
89a5711c
DB
108extern int linux_ptrace_get_extended_event (int wstat);
109extern int linux_is_extended_waitstatus (int wstat);
c9587f88 110extern int linux_wstatus_maybe_breakpoint (int wstat);
87b0bb13 111
af96c192 112#endif /* COMMON_LINUX_PTRACE_H */
This page took 0.335662 seconds and 4 git commands to generate.