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 LLDB_UTILITY_STATE_H
11 #define LLDB_UTILITY_STATE_H
13 #include "lldb/lldb-enumerations.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/FormatProviders.h"
16 #include "llvm/Support/raw_ostream.h"
19 namespace lldb_private {
21 //------------------------------------------------------------------
22 /// Converts a StateType to a C string.
25 /// The StateType object to convert.
28 /// A NULL terminated C string that describes \a state. The
29 /// returned string comes from constant string buffers and does
30 /// not need to be freed.
31 //------------------------------------------------------------------
32 const char *StateAsCString(lldb::StateType state);
34 //------------------------------------------------------------------
35 /// Check if a state represents a state where the process or thread
39 /// The StateType enumeration value
42 /// \b true if the state represents a process or thread state
43 /// where the process or thread is running, \b false otherwise.
44 //------------------------------------------------------------------
45 bool StateIsRunningState(lldb::StateType state);
47 //------------------------------------------------------------------
48 /// Check if a state represents a state where the process or thread
49 /// is stopped. Stopped can mean stopped when the process is still
50 /// around, or stopped when the process has exited or doesn't exist
51 /// yet. The \a must_exist argument tells us which of these cases is
55 /// The StateType enumeration value
57 /// @param[in] must_exist
58 /// A boolean that indicates the thread must also be alive
59 /// so states like unloaded or exited won't return true.
62 /// \b true if the state represents a process or thread state
63 /// where the process or thread is stopped. If \a must_exist is
64 /// \b true, then the process can't be exited or unloaded,
65 /// otherwise exited and unloaded or other states where the
66 /// process no longer exists are considered to be stopped.
67 //------------------------------------------------------------------
68 bool StateIsStoppedState(lldb::StateType state, bool must_exist);
70 const char *GetPermissionsAsCString(uint32_t permissions);
72 } // namespace lldb_private
75 template <> struct format_provider<lldb::StateType> {
76 static void format(const lldb::StateType &state, raw_ostream &Stream,
78 Stream << lldb_private::StateAsCString(state);
83 #endif // LLDB_UTILITY_STATE_H