@@ -229,176 +229,6 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
229229 return pfunc (SWIGBridge::ToSWIGWrapper (std::move (debugger_sp)), dict);
230230}
231231
232- PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedBreakpointResolver (
233- const char *python_class_name, const char *session_dictionary_name,
234- const StructuredDataImpl &args_impl,
235- const lldb::BreakpointSP &breakpoint_sp) {
236-
237- if (python_class_name == NULL || python_class_name[0 ] == ' \0 ' ||
238- !session_dictionary_name)
239- return PythonObject ();
240-
241- PyErr_Cleaner py_err_cleaner (true );
242-
243- auto dict = PythonModule::MainModule ().ResolveName <PythonDictionary>(
244- session_dictionary_name);
245- auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(
246- python_class_name, dict);
247-
248- if (!pfunc.IsAllocated ())
249- return PythonObject ();
250-
251- PythonObject result =
252- pfunc (SWIGBridge::ToSWIGWrapper (breakpoint_sp), SWIGBridge::ToSWIGWrapper (args_impl), dict);
253- // FIXME: At this point we should check that the class we found supports all
254- // the methods that we need.
255-
256- if (result.IsAllocated ()) {
257- // Check that __callback__ is defined:
258- auto callback_func = result.ResolveName <PythonCallable>(" __callback__" );
259- if (callback_func.IsAllocated ())
260- return result;
261- }
262- return PythonObject ();
263- }
264-
265- unsigned int lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResolver (
266- void *implementor, const char *method_name,
267- lldb_private::SymbolContext *sym_ctx) {
268- PyErr_Cleaner py_err_cleaner (false );
269- PythonObject self (PyRefType::Borrowed, static_cast <PyObject *>(implementor));
270- auto pfunc = self.ResolveName <PythonCallable>(method_name);
271-
272- if (!pfunc.IsAllocated ())
273- return 0 ;
274-
275- PythonObject result = sym_ctx ? pfunc (SWIGBridge::ToSWIGWrapper (*sym_ctx)) : pfunc ();
276-
277- if (PyErr_Occurred ()) {
278- PyErr_Print ();
279- PyErr_Clear ();
280- return 0 ;
281- }
282-
283- // The callback will return a bool, but we're need to also return ints
284- // so we're squirrelling the bool through as an int... And if you return
285- // nothing, we'll continue.
286- if (strcmp (method_name, " __callback__" ) == 0 ) {
287- if (result.get () == Py_False)
288- return 0 ;
289- else
290- return 1 ;
291- }
292-
293- long long ret_val = unwrapOrSetPythonException (As<long long >(result));
294-
295- if (PyErr_Occurred ()) {
296- PyErr_Print ();
297- PyErr_Clear ();
298- return 0 ;
299- }
300-
301- return ret_val;
302- }
303-
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-
402232// wrapper that calls an optional instance member of an object taking no
403233// arguments
404234static PyObject *LLDBSwigPython_CallOptionalMember (
@@ -652,6 +482,18 @@ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBStream(PyObject * dat
652482 return sb_ptr;
653483}
654484
485+ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBSymbolContext (PyObject * data) {
486+ lldb::SBSymbolContext *sb_ptr = nullptr ;
487+
488+ int valid_cast =
489+ SWIG_ConvertPtr (data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBSymbolContext, 0 );
490+
491+ if (valid_cast == -1 )
492+ return NULL ;
493+
494+ return sb_ptr;
495+ }
496+
655497void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBValue (PyObject * data) {
656498 lldb::SBValue *sb_ptr = NULL ;
657499
@@ -677,6 +519,19 @@ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyOb
677519 return sb_ptr;
678520}
679521
522+ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext (PyObject *
523+ data) {
524+ lldb::SBExecutionContext *sb_ptr = NULL ;
525+
526+ int valid_cast = SWIG_ConvertPtr (data, (void **)&sb_ptr,
527+ SWIGTYPE_p_lldb__SBExecutionContext, 0 );
528+
529+ if (valid_cast == -1 )
530+ return NULL ;
531+
532+ return sb_ptr;
533+ }
534+
680535bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand (
681536 const char *python_function_name, const char *session_dictionary_name,
682537 lldb::DebuggerSP debugger, const char *args,
0 commit comments