gdb/riscv: Add command to switch between numeric & abi register names
[binutils-gdb.git] / gdb / target / waitstatus.c
blob9e9b5633b12d803dc2e9d9ac95d38a232525e86c
1 /* Target waitstatus implementations.
3 Copyright (C) 1990-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/>. */
20 #include "waitstatus.h"
21 #include "gdbsupport/gdb_signals.h"
23 /* See waitstatus.h. */
25 std::string
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. */
33 DIAGNOSTIC_PUSH
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 case TARGET_WAITKIND_THREAD_CLONED:
49 return string_appendf (str, ", child_ptid = %s",
50 this->child_ptid ().to_string ().c_str ());
52 case TARGET_WAITKIND_EXECD:
53 return string_appendf (str, ", execd_pathname = %s",
54 this->execd_pathname ());
56 case TARGET_WAITKIND_LOADED:
57 case TARGET_WAITKIND_VFORK_DONE:
58 case TARGET_WAITKIND_SPURIOUS:
59 case TARGET_WAITKIND_SYSCALL_ENTRY:
60 case TARGET_WAITKIND_SYSCALL_RETURN:
61 case TARGET_WAITKIND_IGNORE:
62 case TARGET_WAITKIND_NO_HISTORY:
63 case TARGET_WAITKIND_NO_RESUMED:
64 case TARGET_WAITKIND_THREAD_CREATED:
65 return str;
67 DIAGNOSTIC_POP
69 gdb_assert_not_reached ("invalid target_waitkind value: %d",
70 (int) this->kind ());