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