gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdbsupport / gdb_wait.h
CommitLineData
03f2053f 1/* Standard wait macros.
b811d2c2 2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
03f2053f
AC
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
03f2053f
AC
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
03f2053f 18
1a5c2598
TT
19#ifndef COMMON_GDB_WAIT_H
20#define COMMON_GDB_WAIT_H
03f2053f
AC
21
22#ifdef HAVE_SYS_WAIT_H
23#include <sys/wait.h> /* POSIX */
24#else
25#ifdef HAVE_WAIT_H
26#include <wait.h> /* legacy */
27#endif
28#endif
29
30/* Define how to access the int that the wait system call stores.
31 This has been compatible in all Unix systems since time immemorial,
32 but various well-meaning people have defined various different
33 words for the same old bits in the same old int (sometimes claimed
34 to be a struct). We just know it's an int and we use these macros
35 to access the bits. */
36
37/* The following macros are defined equivalently to their definitions
38 in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1
39 <sys/wait.h> defines, since our code does not use waitpid() (but
a4b6fc86 40 NOTE exception for GNU/Linux below). We also fail to declare
559e7e50
EZ
41 wait() and waitpid().
42
43 For MinGW, we use the fact that when a Windows program is
44 terminated by a fatal exception, its exit code is the value of that
45 exception, as defined by the various EXCEPTION_* symbols in the
46 Windows API headers. See also gdb_wait.c. */
03f2053f
AC
47
48#ifndef WIFEXITED
559e7e50
EZ
49# ifdef __MINGW32__
50# define WIFEXITED(w) (((w) & 0xC0000000) == 0)
51# else
52# define WIFEXITED(w) (((w)&0377) == 0)
53# endif
03f2053f
AC
54#endif
55
56#ifndef WIFSIGNALED
559e7e50
EZ
57# ifdef __MINGW32__
58# define WIFSIGNALED(w) (((w) & 0xC0000000) == 0xC0000000)
59# else
60# define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
61# endif
03f2053f
AC
62#endif
63
64#ifndef WIFSTOPPED
65#ifdef IBM6000
66
559e7e50 67/* Unfortunately, the above comment (about being compatible in all Unix
03f2053f
AC
68 systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate
69 status words like 0x57c (sigtrap received after load), and gdb would
0963b4bd 70 choke on it. */
03f2053f
AC
71
72#define WIFSTOPPED(w) ((w)&0x40)
73
74#else
75#define WIFSTOPPED(w) (((w)&0377) == 0177)
76#endif
77#endif
78
79#ifndef WEXITSTATUS
559e7e50
EZ
80# ifdef __MINGW32__
81# define WEXITSTATUS(w) ((w) & ~0xC0000000)
82# else
83# define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
84# endif
03f2053f
AC
85#endif
86
87#ifndef WTERMSIG
559e7e50
EZ
88# ifdef __MINGW32__
89extern int windows_status_to_termsig (unsigned long);
90# define WTERMSIG(w) windows_status_to_termsig (w)
91# else
92# define WTERMSIG(w) ((w) & 0177)
93# endif
03f2053f
AC
94#endif
95
96#ifndef WSTOPSIG
97#define WSTOPSIG WEXITSTATUS
98#endif
99
100/* These are not defined in POSIX, but are used by our programs. */
101
03f2053f 102#ifndef WSETEXIT
ca9c33a5
MS
103# ifdef W_EXITCODE
104#define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
105# else
03f2053f 106#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
ca9c33a5 107# endif
03f2053f
AC
108#endif
109
963843d4
DE
110#ifndef W_STOPCODE
111#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
112#endif
113
03f2053f 114#ifndef WSETSTOP
6d5a5207 115#define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
03f2053f
AC
116#endif
117
a4b6fc86
AC
118/* For native GNU/Linux we may use waitpid and the __WCLONE option.
119 <GRIPE> It is of course dangerous not to use the REAL header file...
120 </GRIPE>. */
03f2053f
AC
121
122/* Bits in the third argument to `waitpid'. */
123#ifndef WNOHANG
124#define WNOHANG 1 /* Don't block waiting. */
125#endif
126
127#ifndef WUNTRACED
128#define WUNTRACED 2 /* Report status of stopped children. */
129#endif
130
131#ifndef __WCLONE
132#define __WCLONE 0x80000000 /* Wait for cloned process. */
133#endif
134
1a5c2598 135#endif /* COMMON_GDB_WAIT_H */
This page took 1.409217 seconds and 4 git commands to generate.