BreakpointID.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //===-- BreakpointID.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_BREAKPOINT_BREAKPOINTID_H
  9. #define LLDB_BREAKPOINT_BREAKPOINTID_H
  10. #include "lldb/lldb-private.h"
  11. #include "llvm/ADT/ArrayRef.h"
  12. #include "llvm/ADT/Optional.h"
  13. #include "llvm/ADT/StringRef.h"
  14. namespace lldb_private {
  15. // class BreakpointID
  16. class BreakpointID {
  17. public:
  18. BreakpointID(lldb::break_id_t bp_id = LLDB_INVALID_BREAK_ID,
  19. lldb::break_id_t loc_id = LLDB_INVALID_BREAK_ID);
  20. virtual ~BreakpointID();
  21. lldb::break_id_t GetBreakpointID() const { return m_break_id; }
  22. lldb::break_id_t GetLocationID() const { return m_location_id; }
  23. void SetID(lldb::break_id_t bp_id, lldb::break_id_t loc_id) {
  24. m_break_id = bp_id;
  25. m_location_id = loc_id;
  26. }
  27. void SetBreakpointID(lldb::break_id_t bp_id) { m_break_id = bp_id; }
  28. void SetBreakpointLocationID(lldb::break_id_t loc_id) {
  29. m_location_id = loc_id;
  30. }
  31. void GetDescription(Stream *s, lldb::DescriptionLevel level);
  32. static bool IsRangeIdentifier(llvm::StringRef str);
  33. static bool IsValidIDExpression(llvm::StringRef str);
  34. static llvm::ArrayRef<llvm::StringRef> GetRangeSpecifiers();
  35. /// Takes an input string containing the description of a breakpoint or
  36. /// breakpoint and location and returns a BreakpointID filled out with
  37. /// the proper id and location.
  38. ///
  39. /// \param[in] input
  40. /// A string containing JUST the breakpoint description.
  41. /// \return
  42. /// If \p input was not a valid breakpoint ID string, returns
  43. /// \b llvm::None. Otherwise returns a BreakpointID with members filled
  44. /// out accordingly.
  45. static llvm::Optional<BreakpointID>
  46. ParseCanonicalReference(llvm::StringRef input);
  47. /// Takes an input string and checks to see whether it is a breakpoint name.
  48. /// If it is a mal-formed breakpoint name, error will be set to an appropriate
  49. /// error string.
  50. ///
  51. /// \param[in] str
  52. /// A string containing JUST the breakpoint description.
  53. /// \param[out] error
  54. /// If the name is a well-formed breakpoint name, set to success,
  55. /// otherwise set to an error.
  56. /// \return
  57. /// \b true if the name is a breakpoint name (as opposed to an ID or
  58. /// range) false otherwise.
  59. static bool StringIsBreakpointName(llvm::StringRef str, Status &error);
  60. /// Takes a breakpoint ID and the breakpoint location id and returns
  61. /// a string containing the canonical description for the breakpoint
  62. /// or breakpoint location.
  63. ///
  64. /// \param[out] break_id
  65. /// This is the break id.
  66. ///
  67. /// \param[out] break_loc_id
  68. /// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no
  69. /// location is to be specified.
  70. static void GetCanonicalReference(Stream *s, lldb::break_id_t break_id,
  71. lldb::break_id_t break_loc_id);
  72. protected:
  73. lldb::break_id_t m_break_id;
  74. lldb::break_id_t m_location_id;
  75. };
  76. } // namespace lldb_private
  77. #endif // LLDB_BREAKPOINT_BREAKPOINTID_H