Extend objdump's --show-all-symbols option so that it also shows the extra symbols...
[binutils-gdb.git] / gdbsupport / gdb_wait.cc
blob476861db2288a74fc538f73573f8564cb9604f8e
1 /* Support code for standard wait macros in gdb_wait.h.
3 Copyright (C) 2019-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "gdb_wait.h"
23 #ifdef __MINGW32__
25 /* The underlying idea is that when a Windows program is terminated by
26 a fatal exception, its exit code is the value of that exception, as
27 defined by the various EXCEPTION_* symbols in the Windows API
28 headers. We thus emulate WTERMSIG etc. by translating the fatal
29 exception codes to more-or-less equivalent Posix signals.
31 The translation below is not perfect, because a program could
32 legitimately exit normally with a status whose value happens to
33 have the high bits set, but that's extremely rare, to say the
34 least, and it is deemed such a negligibly small probability of
35 false positives is justified by the utility of reporting the
36 terminating signal in the "normal" cases. */
38 # include <signal.h>
40 # define WIN32_LEAN_AND_MEAN
41 # include <windows.h> /* for EXCEPTION_* constants */
43 struct xlate_status
45 /* The exit status (actually, fatal exception code). */
46 DWORD status;
48 /* The corresponding signal value. */
49 int sig;
52 int
53 windows_status_to_termsig (unsigned long status)
55 static const xlate_status status_xlate_tbl[] =
57 {EXCEPTION_ACCESS_VIOLATION, SIGSEGV},
58 {EXCEPTION_IN_PAGE_ERROR, SIGSEGV},
59 {EXCEPTION_INVALID_HANDLE, SIGSEGV},
60 {EXCEPTION_ILLEGAL_INSTRUCTION, SIGILL},
61 {EXCEPTION_NONCONTINUABLE_EXCEPTION, SIGILL},
62 {EXCEPTION_ARRAY_BOUNDS_EXCEEDED, SIGSEGV},
63 {EXCEPTION_FLT_DENORMAL_OPERAND, SIGFPE},
64 {EXCEPTION_FLT_DIVIDE_BY_ZERO, SIGFPE},
65 {EXCEPTION_FLT_INEXACT_RESULT, SIGFPE},
66 {EXCEPTION_FLT_INVALID_OPERATION, SIGFPE},
67 {EXCEPTION_FLT_OVERFLOW, SIGFPE},
68 {EXCEPTION_FLT_STACK_CHECK, SIGFPE},
69 {EXCEPTION_FLT_UNDERFLOW, SIGFPE},
70 {EXCEPTION_INT_DIVIDE_BY_ZERO, SIGFPE},
71 {EXCEPTION_INT_OVERFLOW, SIGFPE},
72 {EXCEPTION_PRIV_INSTRUCTION, SIGILL},
73 {EXCEPTION_STACK_OVERFLOW, SIGSEGV},
74 {CONTROL_C_EXIT, SIGTERM}
77 for (const xlate_status &x : status_xlate_tbl)
78 if (x.status == status)
79 return x.sig;
81 return -1;
84 #endif /* __MINGW32__ */