1 //===-- BreakpointIDList.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_BREAKPOINT_BREAKPOINTIDLIST_H
10 #define LLDB_BREAKPOINT_BREAKPOINTIDLIST_H
11 
12 #include <utility>
13 #include <vector>
14 
15 
16 #include "lldb/lldb-enumerations.h"
17 #include "lldb/Breakpoint/BreakpointID.h"
18 #include "lldb/Breakpoint/BreakpointName.h"
19 #include "lldb/lldb-private.h"
20 
21 namespace lldb_private {
22 
23 // class BreakpointIDList
24 
25 class BreakpointIDList {
26 public:
27   // TODO: Convert this class to StringRef.
28   typedef std::vector<BreakpointID> BreakpointIDArray;
29 
30   BreakpointIDList();
31 
32   virtual ~BreakpointIDList();
33 
34   size_t GetSize() const;
35 
36   const BreakpointID &GetBreakpointIDAtIndex(size_t index) const;
37 
38   bool RemoveBreakpointIDAtIndex(size_t index);
39 
40   void Clear();
41 
42   bool AddBreakpointID(BreakpointID bp_id);
43 
44   bool AddBreakpointID(const char *bp_id);
45 
46   // TODO: This should take a const BreakpointID.
47   bool FindBreakpointID(BreakpointID &bp_id, size_t *position) const;
48 
49   bool FindBreakpointID(const char *bp_id, size_t *position) const;
50 
51   void InsertStringArray(llvm::ArrayRef<const char *> string_array,
52                          CommandReturnObject &result);
53 
54   // Returns a pair consisting of the beginning and end of a breakpoint
55   // ID range expression.  If the input string is not a valid specification,
56   // returns an empty pair.
57   static std::pair<llvm::StringRef, llvm::StringRef>
58   SplitIDRangeExpression(llvm::StringRef in_string);
59 
60   static void FindAndReplaceIDRanges(Args &old_args, Target *target,
61                                      bool allow_locations,
62                                      BreakpointName::Permissions
63                                        ::PermissionKinds purpose,
64                                      CommandReturnObject &result,
65                                      Args &new_args);
66 
67 private:
68   BreakpointIDArray m_breakpoint_ids;
69   BreakpointID m_invalid_id;
70 
71   BreakpointIDList(const BreakpointIDList &) = delete;
72   const BreakpointIDList &operator=(const BreakpointIDList &) = delete;
73 };
74 
75 } // namespace lldb_private
76 
77 #endif // LLDB_BREAKPOINT_BREAKPOINTIDLIST_H
78