Coverage Report

Created: 2023-09-12 09:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Utility/State.h
Line
Count
Source
1
//===-- State.h -------------------------------------------------*- C++ -*-===//
2
//
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
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_UTILITY_STATE_H
10
#define LLDB_UTILITY_STATE_H
11
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"
16
#include <cstdint>
17
18
namespace lldb_private {
19
20
/// Converts a StateType to a C string.
21
///
22
/// \param[in] state
23
///     The StateType object to convert.
24
///
25
/// \return
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);
30
31
/// Check if a state represents a state where the process or thread
32
/// is running.
33
///
34
/// \param[in] state
35
///     The StateType enumeration value
36
///
37
/// \return
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);
41
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
46
/// desired.
47
///
48
/// \param[in] state
49
///     The StateType enumeration value
50
///
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.
54
///
55
/// \return
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);
62
63
const char *GetPermissionsAsCString(uint32_t permissions);
64
65
} // namespace lldb_private
66
67
namespace llvm {
68
template <> struct format_provider<lldb::StateType> {
69
  static void format(const lldb::StateType &state, raw_ostream &Stream,
70
12
                     StringRef Style) {
71
12
    Stream << lldb_private::StateAsCString(state);
72
12
  }
73
};
74
} // namespace llvm
75
76
#endif // LLDB_UTILITY_STATE_H