1 //===-- State.h -------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_UTILITY_STATE_H
10 #define LLDB_UTILITY_STATE_H
12 #include "lldb/lldb-enumerations.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/FormatProviders.h"
15 #include "llvm/Support/raw_ostream.h"
18 namespace lldb_private {
20 /// Converts a StateType to a C string.
23 /// The StateType object to convert.
26 /// A NULL terminated C string that describes \a state. The
27 /// returned string comes from constant string buffers and does
28 /// not need to be freed.
29 const char *StateAsCString(lldb::StateType state);
31 /// Check if a state represents a state where the process or thread
35 /// The StateType enumeration value
38 /// \b true if the state represents a process or thread state
39 /// where the process or thread is running, \b false otherwise.
40 bool StateIsRunningState(lldb::StateType state);
42 /// Check if a state represents a state where the process or thread
43 /// is stopped. Stopped can mean stopped when the process is still
44 /// around, or stopped when the process has exited or doesn't exist
45 /// yet. The \a must_exist argument tells us which of these cases is
49 /// The StateType enumeration value
51 /// \param[in] must_exist
52 /// A boolean that indicates the thread must also be alive
53 /// so states like unloaded or exited won't return true.
56 /// \b true if the state represents a process or thread state
57 /// where the process or thread is stopped. If \a must_exist is
58 /// \b true, then the process can't be exited or unloaded,
59 /// otherwise exited and unloaded or other states where the
60 /// process no longer exists are considered to be stopped.
61 bool StateIsStoppedState(lldb::StateType state, bool must_exist);
63 const char *GetPermissionsAsCString(uint32_t permissions);
65 } // namespace lldb_private
68 template <> struct format_provider<lldb::StateType> {
69 static void format(const lldb::StateType &state, raw_ostream &Stream,
71 Stream << lldb_private::StateAsCString(state);
76 #endif // LLDB_UTILITY_STATE_H