State.h 2.5 KB

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