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