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 BreakpointResolver *
34   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
35                            const StructuredData::Dictionary &options_dict,
36                            Status &error);
37 
38   StructuredData::ObjectSP SerializeToStructuredData() override;
39 
40   void ResolveBreakpoint(SearchFilter &filter) override;
41 
42   void ResolveBreakpointInModules(SearchFilter &filter,
43                                   ModuleList &modules) override;
44 
45   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
46                                           SymbolContext &context,
47                                           Address *addr) override;
48 
49   lldb::SearchDepth GetDepth() override;
50 
51   void GetDescription(Stream *s) override;
52 
53   void Dump(Stream *s) const override;
54 
55   /// Methods for support type inquiry through isa, cast, and dyn_cast:
56   static inline bool classof(const BreakpointResolverAddress *) { return true; }
57   static inline bool classof(const BreakpointResolver *V) {
58     return V->getResolverID() == BreakpointResolver::AddressResolver;
59   }
60 
61   lldb::BreakpointResolverSP
62   CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
63 
64 protected:
65   Address m_addr;               // The address - may be Section Offset or
66                                 // may be just an offset
67   lldb::addr_t m_resolved_addr; // The current value of the resolved load
68                                 // address for this breakpoint,
69   FileSpec m_module_filespec;   // If this filespec is Valid, and m_addr is an
70                                 // offset, then it will be converted
71   // to a Section+Offset address in this module, whenever that module gets
72   // around to being loaded.
73 private:
74   BreakpointResolverAddress(const BreakpointResolverAddress &) = delete;
75   const BreakpointResolverAddress &
76   operator=(const BreakpointResolverAddress &) = delete;
77 };
78 
79 } // namespace lldb_private
80 
81 #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H
82