1 //===-- State.h -------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_State_h_
11 #define liblldb_State_h_
13 #include "llvm/Support/FormatProviders.h"
15 #include "lldb/lldb-enumerations.h" // for StateType
16 #include "llvm/ADT/StringRef.h" // for StringRef
17 #include "llvm/Support/raw_ostream.h" // for raw_ostream
19 #include <stdint.h> // for uint32_t
21 namespace lldb_private {
23 //------------------------------------------------------------------
24 /// Converts a StateType to a C string.
27 /// The StateType object to convert.
30 /// A NULL terminated C string that describes \a state. The
31 /// returned string comes from constant string buffers and does
32 /// not need to be freed.
33 //------------------------------------------------------------------
34 const char *StateAsCString(lldb::StateType state);
36 //------------------------------------------------------------------
37 /// Check if a state represents a state where the process or thread
41 /// The StateType enumeration value
44 /// \b true if the state represents a process or thread state
45 /// where the process or thread is running, \b false otherwise.
46 //------------------------------------------------------------------
47 bool StateIsRunningState(lldb::StateType state);
49 //------------------------------------------------------------------
50 /// Check if a state represents a state where the process or thread
51 /// is stopped. Stopped can mean stopped when the process is still
52 /// around, or stopped when the process has exited or doesn't exist
53 /// yet. The \a must_exist argument tells us which of these cases is
57 /// The StateType enumeration value
59 /// @param[in] must_exist
60 /// A boolean that indicates the thread must also be alive
61 /// so states like unloaded or exited won't return true.
64 /// \b true if the state represents a process or thread state
65 /// where the process or thread is stopped. If \a must_exist is
66 /// \b true, then the process can't be exited or unloaded,
67 /// otherwise exited and unloaded or other states where the
68 /// process no longer exists are considered to be stopped.
69 //------------------------------------------------------------------
70 bool StateIsStoppedState(lldb::StateType state, bool must_exist);
72 const char *GetPermissionsAsCString(uint32_t permissions);
74 } // namespace lldb_private
77 template <> struct format_provider<lldb::StateType> {
78 static void format(const lldb::StateType &state, raw_ostream &Stream,
80 Stream << lldb_private::StateAsCString(state);
85 #endif // liblldb_State_h_