1 //===-- BreakpointResolverScripted.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 liblldb_BreakpointResolverScripted_h_
10 #define liblldb_BreakpointResolverScripted_h_
11 
12 #include "lldb/lldb-forward.h"
13 #include "lldb/Breakpoint/BreakpointResolver.h"
14 #include "lldb/Core/ModuleSpec.h"
15 
16 
17 namespace lldb_private {
18 
19 //----------------------------------------------------------------------
20 /// @class BreakpointResolverScripted BreakpointResolverScripted.h
21 /// "lldb/Breakpoint/BreakpointResolverScripted.h" This class sets breakpoints
22 /// on a given Address.  This breakpoint only takes once, and then it won't
23 /// attempt to reset itself.
24 //----------------------------------------------------------------------
25 
26 class BreakpointResolverScripted : public BreakpointResolver {
27 public:
28   BreakpointResolverScripted(Breakpoint *bkpt,
29                              const llvm::StringRef class_name,
30                              lldb::SearchDepth depth,
31                              StructuredDataImpl *args_data,
32                              ScriptInterpreter &script_interp);
33 
34   ~BreakpointResolverScripted() override;
35 
36   static BreakpointResolver *
37   CreateFromStructuredData(Breakpoint *bkpt,
38                            const StructuredData::Dictionary &options_dict,
39                            Status &error);
40 
41   StructuredData::ObjectSP SerializeToStructuredData() override;
42 
43   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
44                                           SymbolContext &context, Address *addr,
45                                           bool containing) override;
46 
47   lldb::SearchDepth GetDepth() override;
48 
49   void GetDescription(Stream *s) override;
50 
51   void Dump(Stream *s) const override;
52 
53   /// Methods for support type inquiry through isa, cast, and dyn_cast:
54   static inline bool classof(const BreakpointResolverScripted *) { return true; }
55   static inline bool classof(const BreakpointResolver *V) {
56     return V->getResolverID() == BreakpointResolver::PythonResolver;
57   }
58 
59   lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
60 
61 protected:
62   void NotifyBreakpointSet() override;
63 private:
64   void CreateImplementationIfNeeded();
65   ScriptInterpreter *GetScriptInterpreter();
66 
67   std::string m_class_name;
68   lldb::SearchDepth m_depth;
69   StructuredDataImpl *m_args_ptr; // We own this, but the implementation
70                                   // has to manage the UP (since that is
71                                   // how it gets stored in the
72                                   // SBStructuredData).
73   StructuredData::GenericSP m_implementation_sp;
74 
75   DISALLOW_COPY_AND_ASSIGN(BreakpointResolverScripted);
76 };
77 
78 } // namespace lldb_private
79 
80 #endif // liblldb_BreakpointResolverScripted_h_
81