]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/State.h
MFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Core / State.h
1 //===-- State.h -------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_State_h_
11 #define liblldb_State_h_
12
13 #include "llvm/Support/FormatProviders.h"
14
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
18
19 #include <stdint.h> // for uint32_t
20
21 namespace lldb_private {
22
23 //------------------------------------------------------------------
24 /// Converts a StateType to a C string.
25 ///
26 /// @param[in] state
27 ///     The StateType object to convert.
28 ///
29 /// @return
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);
35
36 //------------------------------------------------------------------
37 /// Check if a state represents a state where the process or thread
38 /// is running.
39 ///
40 /// @param[in] state
41 ///     The StateType enumeration value
42 ///
43 /// @return
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);
48
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
54 /// desired.
55 ///
56 /// @param[in] state
57 ///     The StateType enumeration value
58 ///
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.
62 ///
63 /// @return
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);
71
72 const char *GetPermissionsAsCString(uint32_t permissions);
73
74 } // namespace lldb_private
75
76 namespace llvm {
77 template <> struct format_provider<lldb::StateType> {
78   static void format(const lldb::StateType &state, raw_ostream &Stream,
79                      StringRef Style) {
80     Stream << lldb_private::StateAsCString(state);
81   }
82 };
83 }
84
85 #endif // liblldb_State_h_