@@ -301,104 +301,6 @@ unsigned int lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResol
301301 return ret_val;
302302}
303303
304- PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopHook (
305- lldb::TargetSP target_sp, const char *python_class_name,
306- const char *session_dictionary_name, const StructuredDataImpl &args_impl,
307- Status &error) {
308- if (python_class_name == NULL || python_class_name[0 ] == ' \0 ' ) {
309- error = Status::FromErrorString (" Empty class name." );
310- return PythonObject ();
311- }
312- if (!session_dictionary_name) {
313- error = Status::FromErrorString (" No session dictionary" );
314- return PythonObject ();
315- }
316-
317- PyErr_Cleaner py_err_cleaner (true );
318-
319- auto dict = PythonModule::MainModule ().ResolveName <PythonDictionary>(
320- session_dictionary_name);
321- auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
322- python_class_name, dict);
323-
324- if (!pfunc.IsAllocated ()) {
325- error = Status::FromErrorStringWithFormat (" Could not find class: %s." ,
326- python_class_name);
327- return PythonObject ();
328- }
329-
330- PythonObject result =
331- pfunc (SWIGBridge::ToSWIGWrapper (target_sp), SWIGBridge::ToSWIGWrapper (args_impl), dict);
332-
333- if (result.IsAllocated ()) {
334- // Check that the handle_stop callback is defined:
335- auto callback_func = result.ResolveName <PythonCallable>(" handle_stop" );
336- if (callback_func.IsAllocated ()) {
337- if (auto args_info = callback_func.GetArgInfo ()) {
338- size_t num_args = (*args_info).max_positional_args ;
339- if (num_args != 2 ) {
340- error = Status::FromErrorStringWithFormat (
341- " Wrong number of args for "
342- " handle_stop callback, should be 2 (excluding self), got: %zu" ,
343- num_args);
344- return PythonObject ();
345- } else
346- return result;
347- } else {
348- error = Status::FromErrorString (
349- " Couldn't get num arguments for handle_stop "
350- " callback." );
351- return PythonObject ();
352- }
353- return result;
354- } else {
355- error = Status::FromErrorStringWithFormat (
356- " Class \" %s\" is missing the required "
357- " handle_stop callback." ,
358- python_class_name);
359- }
360- }
361- return PythonObject ();
362- }
363-
364- bool lldb_private::python::SWIGBridge::LLDBSwigPythonStopHookCallHandleStop (
365- void *implementor, lldb::ExecutionContextRefSP exc_ctx_sp,
366- lldb::StreamSP stream) {
367- // handle_stop will return a bool with the meaning "should_stop"...
368- // If you return nothing we'll assume we are going to stop.
369- // Also any errors should return true, since we should stop on error.
370-
371- PyErr_Cleaner py_err_cleaner (false );
372- PythonObject self (PyRefType::Borrowed, static_cast <PyObject *>(implementor));
373- auto pfunc = self.ResolveName <PythonCallable>(" handle_stop" );
374-
375- if (!pfunc.IsAllocated ())
376- return true ;
377-
378- std::shared_ptr<lldb::SBStream> sb_stream = std::make_shared<lldb::SBStream>();
379- PythonObject sb_stream_arg = SWIGBridge::ToSWIGWrapper (sb_stream);
380- PythonObject result =
381- pfunc (SWIGBridge::ToSWIGWrapper (std::move (exc_ctx_sp)), sb_stream_arg);
382-
383- if (PyErr_Occurred ()) {
384- stream->PutCString (" Python error occurred handling stop-hook." );
385- PyErr_Print ();
386- PyErr_Clear ();
387- return true ;
388- }
389-
390- // Now add the result to the output stream. SBStream only
391- // makes an internally help StreamString which I can't interpose, so I
392- // have to copy it over here.
393- stream->PutCString (sb_stream->GetData ());
394- sb_stream_arg.release ();
395-
396- if (result.get () == Py_False)
397- return false ;
398- else
399- return true ;
400- }
401-
402304// wrapper that calls an optional instance member of an object taking no
403305// arguments
404306static PyObject *LLDBSwigPython_CallOptionalMember (
@@ -677,6 +579,19 @@ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyOb
677579 return sb_ptr;
678580}
679581
582+ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext (PyObject *
583+ data) {
584+ lldb::SBExecutionContext *sb_ptr = NULL ;
585+
586+ int valid_cast = SWIG_ConvertPtr (data, (void **)&sb_ptr,
587+ SWIGTYPE_p_lldb__SBExecutionContext, 0 );
588+
589+ if (valid_cast == -1 )
590+ return NULL ;
591+
592+ return sb_ptr;
593+ }
594+
680595bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand (
681596 const char *python_function_name, const char *session_dictionary_name,
682597 lldb::DebuggerSP debugger, const char *args,
0 commit comments