@@ -35,7 +35,7 @@ BreakpointResolverScripted::BreakpointResolverScripted(
3535
3636void BreakpointResolverScripted::CreateImplementationIfNeeded (
3737 BreakpointSP breakpoint_sp) {
38- if (m_implementation_sp )
38+ if (m_interface_sp )
3939 return ;
4040
4141 if (m_class_name.empty ())
@@ -50,8 +50,28 @@ void BreakpointResolverScripted::CreateImplementationIfNeeded(
5050 if (!script_interp)
5151 return ;
5252
53- m_implementation_sp = script_interp->CreateScriptedBreakpointResolver (
54- m_class_name.c_str (), m_args, breakpoint_sp);
53+ m_interface_sp = script_interp->CreateScriptedBreakpointInterface ();
54+ if (!m_interface_sp) {
55+ m_error = Status::FromErrorStringWithFormat (
56+ " BreakpointResolverScripted::%s () - ERROR: %s" , __FUNCTION__,
57+ " Script interpreter couldn't create Scripted Breakpoint Interface" );
58+ return ;
59+ }
60+
61+ auto obj_or_err = m_interface_sp->CreatePluginObject (
62+ m_class_name, breakpoint_sp, m_args);
63+ if (!obj_or_err) {
64+ m_error = Status::FromError (obj_or_err.takeError ());
65+ printf (" CreateImplementationIfNeeded got error: %s\n " , m_error.AsCString ());
66+ return ;
67+ }
68+
69+ StructuredData::ObjectSP object_sp = *obj_or_err;
70+ if (!object_sp || !object_sp->IsValid ()) {
71+ m_error = Status::FromErrorStringWithFormat (
72+ " ScriptedBreakpoint::%s () - ERROR: %s" , __FUNCTION__,
73+ " Failed to create valid script object" );
74+ }
5575}
5676
5777void BreakpointResolverScripted::NotifyBreakpointSet () {
@@ -104,13 +124,10 @@ ScriptInterpreter *BreakpointResolverScripted::GetScriptInterpreter() {
104124Searcher::CallbackReturn BreakpointResolverScripted::SearchCallback (
105125 SearchFilter &filter, SymbolContext &context, Address *addr) {
106126 bool should_continue = true ;
107- if (!m_implementation_sp )
127+ if (!m_interface_sp )
108128 return Searcher::eCallbackReturnStop;
109129
110- ScriptInterpreter *interp = GetScriptInterpreter ();
111- should_continue = interp->ScriptedBreakpointResolverSearchCallback (
112- m_implementation_sp,
113- &context);
130+ should_continue = m_interface_sp->ResolverCallback (context);
114131 if (should_continue)
115132 return Searcher::eCallbackReturnContinue;
116133
@@ -120,25 +137,21 @@ Searcher::CallbackReturn BreakpointResolverScripted::SearchCallback(
120137lldb::SearchDepth
121138BreakpointResolverScripted::GetDepth () {
122139 lldb::SearchDepth depth = lldb::eSearchDepthModule;
123- if (m_implementation_sp) {
124- ScriptInterpreter *interp = GetScriptInterpreter ();
125- depth = interp->ScriptedBreakpointResolverSearchDepth (
126- m_implementation_sp);
127- }
140+ if (m_interface_sp)
141+ depth = m_interface_sp->GetDepth ();
142+
128143 return depth;
129144}
130145
131146void BreakpointResolverScripted::GetDescription (Stream *s) {
132147 StructuredData::GenericSP generic_sp;
133- std::string short_help;
148+ std::optional<std:: string> short_help;
134149
135- if (m_implementation_sp) {
136- ScriptInterpreter *interp = GetScriptInterpreter ();
137- interp->GetShortHelpForCommandObject (m_implementation_sp,
138- short_help);
150+ if (m_interface_sp) {
151+ short_help = m_interface_sp->GetShortHelp ();
139152 }
140- if (!short_help. empty ())
141- s->PutCString (short_help. c_str ());
153+ if (short_help && !short_help-> empty ())
154+ s->PutCString (short_help-> c_str ());
142155 else
143156 s->Printf (" python class = %s" , m_class_name.c_str ());
144157}
0 commit comments