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