Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:58

0001 //===-- State.h -------------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_STATE_H
0010 #define LLDB_UTILITY_STATE_H
0011 
0012 #include "lldb/lldb-enumerations.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/Support/FormatProviders.h"
0015 #include "llvm/Support/raw_ostream.h"
0016 #include <cstdint>
0017 
0018 namespace lldb_private {
0019 
0020 /// Converts a StateType to a C string.
0021 ///
0022 /// \param[in] state
0023 ///     The StateType object to convert.
0024 ///
0025 /// \return
0026 ///     A NULL terminated C string that describes \a state. The
0027 ///     returned string comes from constant string buffers and does
0028 ///     not need to be freed.
0029 const char *StateAsCString(lldb::StateType state);
0030 
0031 /// Check if a state represents a state where the process or thread
0032 /// is running.
0033 ///
0034 /// \param[in] state
0035 ///     The StateType enumeration value
0036 ///
0037 /// \return
0038 ///     \b true if the state represents a process or thread state
0039 ///     where the process or thread is running, \b false otherwise.
0040 bool StateIsRunningState(lldb::StateType state);
0041 
0042 /// Check if a state represents a state where the process or thread
0043 /// is stopped. Stopped can mean stopped when the process is still
0044 /// around, or stopped when the process has exited or doesn't exist
0045 /// yet. The \a must_exist argument tells us which of these cases is
0046 /// desired.
0047 ///
0048 /// \param[in] state
0049 ///     The StateType enumeration value
0050 ///
0051 /// \param[in] must_exist
0052 ///     A boolean that indicates the thread must also be alive
0053 ///     so states like unloaded or exited won't return true.
0054 ///
0055 /// \return
0056 ///     \b true if the state represents a process or thread state
0057 ///     where the process or thread is stopped. If \a must_exist is
0058 ///     \b true, then the process can't be exited or unloaded,
0059 ///     otherwise exited and unloaded or other states where the
0060 ///     process no longer exists are considered to be stopped.
0061 bool StateIsStoppedState(lldb::StateType state, bool must_exist);
0062 
0063 const char *GetPermissionsAsCString(uint32_t permissions);
0064 
0065 } // namespace lldb_private
0066 
0067 namespace llvm {
0068 template <> struct format_provider<lldb::StateType> {
0069   static void format(const lldb::StateType &state, raw_ostream &Stream,
0070                      StringRef Style) {
0071     Stream << lldb_private::StateAsCString(state);
0072   }
0073 };
0074 } // namespace llvm
0075 
0076 #endif // LLDB_UTILITY_STATE_H