1 /* Target waitstatus implementations.
3 Copyright (C) 1990-2021 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/>. */
20 #include "gdbsupport/common-defs.h"
21 #include "waitstatus.h"
23 /* See waitstatus.h. */
26 target_waitstatus::to_string () const
28 std::string str
= string_printf
29 ("status->kind = %s", target_waitkind_str (this->kind ()));
31 /* Make sure the compiler warns if a new TARGET_WAITKIND enumerator is added
32 but not handled here. */
34 DIAGNOSTIC_ERROR_SWITCH
35 switch (this->kind ())
37 case TARGET_WAITKIND_EXITED
:
38 case TARGET_WAITKIND_THREAD_EXITED
:
39 return string_appendf (str
, ", exit_status = %d", this->exit_status ());
41 case TARGET_WAITKIND_STOPPED
:
42 case TARGET_WAITKIND_SIGNALLED
:
43 return string_appendf (str
, ", sig = %s",
44 gdb_signal_to_symbol_string (this->sig ()));
46 case TARGET_WAITKIND_FORKED
:
47 case TARGET_WAITKIND_VFORKED
:
48 return string_appendf (str
, ", child_ptid = %s",
49 this->child_ptid ().to_string ().c_str ());
51 case TARGET_WAITKIND_EXECD
:
52 return string_appendf (str
, ", execd_pathname = %s",
53 this->execd_pathname ());
55 case TARGET_WAITKIND_LOADED
:
56 case TARGET_WAITKIND_VFORK_DONE
:
57 case TARGET_WAITKIND_SPURIOUS
:
58 case TARGET_WAITKIND_SYSCALL_ENTRY
:
59 case TARGET_WAITKIND_SYSCALL_RETURN
:
60 case TARGET_WAITKIND_IGNORE
:
61 case TARGET_WAITKIND_NO_HISTORY
:
62 case TARGET_WAITKIND_NO_RESUMED
:
63 case TARGET_WAITKIND_THREAD_CREATED
:
68 gdb_assert_not_reached ("invalid target_waitkind value: %d",