1 //===-- BreakpointResolverAddress.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_BREAKPOINTRESOLVERADDRESS_H
10 #define LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H
11 
12 #include "lldb/Breakpoint/BreakpointResolver.h"
13 #include "lldb/Core/ModuleSpec.h"
14 
15 namespace lldb_private {
16 
17 /// \class BreakpointResolverAddress BreakpointResolverAddress.h
18 /// "lldb/Breakpoint/BreakpointResolverAddress.h" This class sets breakpoints
19 /// on a given Address.  This breakpoint only takes once, and then it won't
20 /// attempt to reset itself.
21 
22 class BreakpointResolverAddress : public BreakpointResolver {
23 public:
24   BreakpointResolverAddress(const lldb::BreakpointSP &bkpt,
25                             const Address &addr);
26 
27   BreakpointResolverAddress(const lldb::BreakpointSP &bkpt,
28                             const Address &addr,
29                             const FileSpec &module_spec);
30 
31   ~BreakpointResolverAddress() override = default;
32 
33   static lldb::BreakpointResolverSP
34   CreateFromStructuredData(const StructuredData::Dictionary &options_dict,
35                            Status &error);
36 
37   StructuredData::ObjectSP SerializeToStructuredData() override;
38 
39   void ResolveBreakpoint(SearchFilter &filter) override;
40 
41   void ResolveBreakpointInModules(SearchFilter &filter,
42                                   ModuleList &modules) override;
43 
44   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
45                                           SymbolContext &context,
46                                           Address *addr) override;
47 
48   lldb::SearchDepth GetDepth() override;
49 
50   void GetDescription(Stream *s) override;
51 
52   void Dump(Stream *s) const override;
53 
54   /// Methods for support type inquiry through isa, cast, and dyn_cast:
classof(const BreakpointResolverAddress *)55   static inline bool classof(const BreakpointResolverAddress *) { return true; }
classof(const BreakpointResolver * V)56   static inline bool classof(const BreakpointResolver *V) {
57     return V->getResolverID() == BreakpointResolver::AddressResolver;
58   }
59 
60   lldb::BreakpointResolverSP
61   CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
62 
63 protected:
64   Address m_addr;               // The address - may be Section Offset or
65                                 // may be just an offset
66   lldb::addr_t m_resolved_addr; // The current value of the resolved load
67                                 // address for this breakpoint,
68   FileSpec m_module_filespec;   // If this filespec is Valid, and m_addr is an
69                                 // offset, then it will be converted
70   // to a Section+Offset address in this module, whenever that module gets
71   // around to being loaded.
72 private:
73   BreakpointResolverAddress(const BreakpointResolverAddress &) = delete;
74   const BreakpointResolverAddress &
75   operator=(const BreakpointResolverAddress &) = delete;
76 };
77 
78 } // namespace lldb_private
79 
80 #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H
81