gdb: target_waitstatus_to_string: print extra info for FORKED, VFORKED, EXECD
[binutils-gdb.git] / gdb / target / waitstatus.c
1 /* Target waitstatus implementations.
2
3 Copyright (C) 1990-2021 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20 #include "gdbsupport/common-defs.h"
21 #include "waitstatus.h"
22
23 /* Return a pretty printed form of target_waitstatus. */
24
25 std::string
26 target_waitstatus_to_string (const struct target_waitstatus *ws)
27 {
28 const char *kind_str = "status->kind = ";
29
30 switch (ws->kind)
31 {
32 case TARGET_WAITKIND_EXITED:
33 return string_printf ("%sexited, status = %d",
34 kind_str, ws->value.integer);
35
36 case TARGET_WAITKIND_STOPPED:
37 return string_printf ("%sstopped, signal = %s",
38 kind_str,
39 gdb_signal_to_symbol_string (ws->value.sig));
40
41 case TARGET_WAITKIND_SIGNALLED:
42 return string_printf ("%ssignalled, signal = %s",
43 kind_str,
44 gdb_signal_to_symbol_string (ws->value.sig));
45
46 case TARGET_WAITKIND_LOADED:
47 return string_printf ("%sloaded", kind_str);
48
49 case TARGET_WAITKIND_FORKED:
50 return string_printf ("%sforked, related_pid = %s", kind_str,
51 ws->value.related_pid.to_string ().c_str ());
52
53 case TARGET_WAITKIND_VFORKED:
54 return string_printf ("%svforked, related_pid = %s", kind_str,
55 ws->value.related_pid.to_string ().c_str ());
56
57 case TARGET_WAITKIND_EXECD:
58 return string_printf ("%sexecd, execd_pathname = %s", kind_str,
59 ws->value.execd_pathname);
60
61 case TARGET_WAITKIND_VFORK_DONE:
62 return string_printf ("%svfork-done", kind_str);
63
64 case TARGET_WAITKIND_SYSCALL_ENTRY:
65 return string_printf ("%sentered syscall", kind_str);
66
67 case TARGET_WAITKIND_SYSCALL_RETURN:
68 return string_printf ("%sexited syscall", kind_str);
69
70 case TARGET_WAITKIND_SPURIOUS:
71 return string_printf ("%sspurious", kind_str);
72
73 case TARGET_WAITKIND_IGNORE:
74 return string_printf ("%signore", kind_str);
75
76 case TARGET_WAITKIND_NO_HISTORY:
77 return string_printf ("%sno-history", kind_str);
78
79 case TARGET_WAITKIND_NO_RESUMED:
80 return string_printf ("%sno-resumed", kind_str);
81
82 case TARGET_WAITKIND_THREAD_CREATED:
83 return string_printf ("%sthread created", kind_str);
84
85 case TARGET_WAITKIND_THREAD_EXITED:
86 return string_printf ("%sthread exited, status = %d",
87 kind_str, ws->value.integer);
88
89 default:
90 return string_printf ("%sunknown???", kind_str);
91 }
92 }