aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Core/State.h
blob: 68f0fee254b39e4b4745ed022a4cdf1f242c2e2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//===-- State.h -------------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_State_h_
#define liblldb_State_h_

#include "llvm/Support/FormatProviders.h"

#include "lldb/lldb-enumerations.h"   // for StateType
#include "llvm/ADT/StringRef.h"       // for StringRef
#include "llvm/Support/raw_ostream.h" // for raw_ostream

#include <stdint.h> // for uint32_t

namespace lldb_private {

//------------------------------------------------------------------
/// Converts a StateType to a C string.
///
/// @param[in] state
///     The StateType object to convert.
///
/// @return
///     A NULL terminated C string that describes \a state. The
///     returned string comes from constant string buffers and does
///     not need to be freed.
//------------------------------------------------------------------
const char *StateAsCString(lldb::StateType state);

//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
/// is running.
///
/// @param[in] state
///     The StateType enumeration value
///
/// @return
///     \b true if the state represents a process or thread state
///     where the process or thread is running, \b false otherwise.
//------------------------------------------------------------------
bool StateIsRunningState(lldb::StateType state);

//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
/// is stopped. Stopped can mean stopped when the process is still
/// around, or stopped when the process has exited or doesn't exist
/// yet. The \a must_exist argument tells us which of these cases is
/// desired.
///
/// @param[in] state
///     The StateType enumeration value
///
/// @param[in] must_exist
///     A boolean that indicates the thread must also be alive
///     so states like unloaded or exited won't return true.
///
/// @return
///     \b true if the state represents a process or thread state
///     where the process or thread is stopped. If \a must_exist is
///     \b true, then the process can't be exited or unloaded,
///     otherwise exited and unloaded or other states where the
///     process no longer exists are considered to be stopped.
//------------------------------------------------------------------
bool StateIsStoppedState(lldb::StateType state, bool must_exist);

const char *GetPermissionsAsCString(uint32_t permissions);

} // namespace lldb_private

namespace llvm {
template <> struct format_provider<lldb::StateType> {
  static void format(const lldb::StateType &state, raw_ostream &Stream,
                     StringRef Style) {
    Stream << lldb_private::StateAsCString(state);
  }
};
}

#endif // liblldb_State_h_