5 SBTypeToSWIGWrapper (T* item);
10 PyErr_Cleaner(bool print=false) :
19 if(m_print && !PyErr_ExceptionMatches(PyExc_SystemExit))
30 ResolvePythonName(const char* name,
36 PyErr_Cleaner pyerr_cleanup(true); // show Python errors
42 pmodule = PyImport_AddModule ("__main__");
47 if (PyType_Check(pmodule))
49 main_dict = ((PyTypeObject*)pmodule)->tp_dict;
53 else if (!PyDict_Check(pmodule))
55 main_dict = PyModule_GetDict (pmodule);
62 const char* dot_pos = ::strchr(name, '.');
64 PyObject *dest_object;
65 PyObject *key, *value;
71 while (PyDict_Next (main_dict, &pos, &key, &value))
73 // We have stolen references to the key and value objects in the dictionary; we need to increment
74 // them now so that Python's garbage collector doesn't collect them out from under us.
77 if (strcmp (PyString_AsString (key), name) == 0)
83 if (!dest_object || dest_object == Py_None)
89 size_t len = dot_pos - name;
90 std::string piece(name,len);
91 pmodule = ResolvePythonName(piece.c_str(), main_dict);
94 return ResolvePythonName(dot_pos+1,pmodule); // tail recursion.. should be optimized by the compiler
99 FindSessionDictionary(const char *session_dictionary_name)
101 return ResolvePythonName(session_dictionary_name, NULL);
116 if (m_callable && PyFunction_Check(m_callable))
118 PyCodeObject* code = (PyCodeObject*)PyFunction_GET_CODE(m_callable);
121 size_t args = code->co_argcount;
122 bool va=false,kw=false;
123 if ((code->co_flags & 4) == 4)
125 if ((code->co_flags & 8) == 8)
130 return {SIZE_MAX,false,false};
136 return m_callable != NULL;
139 template<typename ...Args>
141 operator () (Args... args)
143 return (*this)({SBTypeToSWIGWrapper(args)...});
147 operator () (std::initializer_list<PyObject*> args)
149 PyObject* retval = NULL;
150 PyObject* pargs = PyTuple_New (args.size());
153 if (PyErr_Occurred())
158 for (auto arg : args)
162 Py_INCREF(arg); // _SetItem steals a reference
163 PyTuple_SetItem(pargs,idx,arg);
166 retval = PyObject_CallObject (m_callable, pargs);
172 FindWithPythonObject (PyObject* pfunc)
174 return PyCallable(pfunc);
178 FindWithFunctionName (const char *python_function_name,
179 const char *session_dictionary_name)
181 if (!python_function_name || !session_dictionary_name)
183 if ( (python_function_name[0] == 0) || (session_dictionary_name[0] == 0) )
185 return FindWithFunctionName(python_function_name,FindSessionDictionary (session_dictionary_name));
189 FindWithFunctionName (const char *python_function_name,
190 PyObject *session_dict)
192 if (!python_function_name || !session_dict)
194 if ( (python_function_name[0] == 0))
196 return PyCallable(ResolvePythonName (python_function_name, session_dict));
200 FindWithMemberFunction (PyObject *self,
201 const char *python_function_name)
203 if (self == NULL || self == Py_None)
205 if (!python_function_name || (python_function_name[0] == 0))
207 return PyCallable(PyObject_GetAttrString(self, python_function_name));
211 PyObject* m_callable;
213 PyCallable (PyObject *callable = NULL) :
216 if (m_callable && PyCallable_Check(m_callable) == false)
225 // resolve a dotted Python name in the form
226 // foo.bar.baz.Foobar to an actual Python object
227 // if pmodule is NULL, the __main__ module will be used
228 // as the starting point for the search
231 // This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
232 // and is used when a script command is attached to a breakpoint for execution.
235 LLDBSwigPythonBreakpointCallbackFunction
237 const char *python_function_name,
238 const char *session_dictionary_name,
239 const lldb::StackFrameSP& frame_sp,
240 const lldb::BreakpointLocationSP& bp_loc_sp
243 lldb::SBFrame sb_frame (frame_sp);
244 lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
246 bool stop_at_breakpoint = true;
249 PyErr_Cleaner py_err_cleaner(true);
251 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
254 return stop_at_breakpoint;
256 PyObject* session_dict = NULL;
257 PyObject* pvalue = NULL;
258 pvalue = pfunc(sb_frame, sb_bp_loc, session_dict = FindSessionDictionary(session_dictionary_name));
260 Py_XINCREF (session_dict);
262 if (pvalue == Py_False)
263 stop_at_breakpoint = false;
268 return stop_at_breakpoint;
271 // This function is called by lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...)
272 // and is used when a script command is attached to a watchpoint for execution.
275 LLDBSwigPythonWatchpointCallbackFunction
277 const char *python_function_name,
278 const char *session_dictionary_name,
279 const lldb::StackFrameSP& frame_sp,
280 const lldb::WatchpointSP& wp_sp
283 lldb::SBFrame sb_frame (frame_sp);
284 lldb::SBWatchpoint sb_wp(wp_sp);
286 bool stop_at_watchpoint = true;
289 PyErr_Cleaner py_err_cleaner(true);
291 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
294 return stop_at_watchpoint;
296 PyObject* session_dict = NULL;
297 PyObject* pvalue = NULL;
298 pvalue = pfunc(sb_frame, sb_wp, session_dict = FindSessionDictionary(session_dictionary_name));
300 Py_XINCREF (session_dict);
302 if (pvalue == Py_False)
303 stop_at_watchpoint = false;
308 return stop_at_watchpoint;
312 PyObjectToString (PyObject* object,
317 if (object != NULL && object != Py_None)
319 if (PyString_Check(object))
321 retval.assign(PyString_AsString(object));
326 PyObject* value_as_string = PyObject_Str(object);
327 if (value_as_string && value_as_string != Py_None && PyString_Check(value_as_string))
329 retval.assign(PyString_AsString(value_as_string));
332 Py_XDECREF(value_as_string);
339 LLDBSwigPythonCallTypeScript
341 const char *python_function_name,
342 const void *session_dictionary,
343 const lldb::ValueObjectSP& valobj_sp,
344 void** pyfunct_wrapper,
345 const lldb::TypeSummaryOptionsSP& options_sp,
349 lldb::SBValue sb_value (valobj_sp);
350 lldb::SBTypeSummaryOptions sb_options(options_sp.get());
354 if (!python_function_name || !session_dictionary)
357 PyObject *session_dict = (PyObject*)session_dictionary, *pfunc_impl = NULL, *pvalue = NULL;
359 if (pyfunct_wrapper && *pyfunct_wrapper && PyFunction_Check (*pyfunct_wrapper))
361 pfunc_impl = (PyObject*)(*pyfunct_wrapper);
362 if (pfunc_impl->ob_refcnt == 1)
364 Py_XDECREF(pfunc_impl);
369 if (PyDict_Check(session_dict))
371 PyErr_Cleaner pyerr_cleanup(true); // show Python errors
375 pfunc_impl = ResolvePythonName (python_function_name, session_dict);
376 if (!pfunc_impl || !PyCallable_Check (pfunc_impl))
381 *pyfunct_wrapper = pfunc_impl;
385 PyCallable pfunc = PyCallable::FindWithPythonObject(pfunc_impl);
390 // if the third argument is supported, or varargs are allowed
391 PyCallable::argc argc = pfunc.GetNumArguments();
392 if (argc.num_args == 3 || argc.varargs == true)
393 pvalue = pfunc(sb_value,session_dict,sb_options);
395 pvalue = pfunc(sb_value,session_dict);
397 pvalue = pfunc(sb_value,session_dict);
399 Py_INCREF (session_dict);
401 PyObjectToString(pvalue,retval);
409 LLDBSwigPythonCreateSyntheticProvider
411 const char *python_class_name,
412 const char *session_dictionary_name,
413 const lldb::ValueObjectSP& valobj_sp
416 PyObject* retval = NULL;
418 if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
421 // I do not want the SBValue to be deallocated when going out of scope because python
422 // has ownership of it and will manage memory for this object by itself
423 lldb::SBValue *sb_value = new lldb::SBValue(valobj_sp);
424 sb_value->SetPreferSyntheticValue(false);
425 PyObject *ValObj_PyObj = SBTypeToSWIGWrapper(sb_value);
427 if (ValObj_PyObj == NULL)
431 PyErr_Cleaner py_err_cleaner(true);
433 PyCallable pfunc = PyCallable::FindWithFunctionName(python_class_name,session_dictionary_name);
438 Py_INCREF(ValObj_PyObj);
440 PyObject* session_dict = NULL;
441 session_dict = FindSessionDictionary(session_dictionary_name);
442 retval = pfunc(sb_value, session_dict);
444 Py_XINCREF (session_dict);
456 LLDBSwigPythonCreateCommandObject
458 const char *python_class_name,
459 const char *session_dictionary_name,
460 const lldb::DebuggerSP debugger_sp
463 PyObject* retval = NULL;
465 if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
468 lldb::SBDebugger debugger_sb(debugger_sp);
471 PyErr_Cleaner py_err_cleaner(true);
473 PyCallable pfunc = PyCallable::FindWithFunctionName(python_class_name,session_dictionary_name);
478 PyObject* session_dict = NULL;
479 session_dict = FindSessionDictionary(session_dictionary_name);
480 retval = pfunc(debugger_sb, session_dict);
482 Py_XINCREF (session_dict);
494 LLDBSwigPythonCreateScriptedThreadPlan
496 const char *python_class_name,
497 const char *session_dictionary_name,
498 const lldb::ThreadPlanSP& thread_plan_sp
501 PyObject* retval = NULL;
503 if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
506 // I do not want the SBThreadPlan to be deallocated when going out of scope because python
507 // has ownership of it and will manage memory for this object by itself
508 lldb::SBThreadPlan *tp_value = new lldb::SBThreadPlan(thread_plan_sp);
510 PyObject *ThreadPlan_PyObj = SBTypeToSWIGWrapper(tp_value);
512 if (ThreadPlan_PyObj == NULL)
516 PyErr_Cleaner py_err_cleaner(true);
518 PyCallable pfunc = PyCallable::FindWithFunctionName(python_class_name, session_dictionary_name);
523 Py_INCREF(ThreadPlan_PyObj);
525 PyObject* session_dict = NULL;
526 session_dict = FindSessionDictionary(session_dictionary_name);
527 retval = pfunc(tp_value, session_dict);
529 // FIXME: At this point we should check that the class we found supports all the methods
532 Py_XINCREF (session_dict);
544 LLDBSWIGPythonCallThreadPlan
547 const char *method_name,
548 lldb_private::Event *event,
552 bool ret_val = false;
556 PyErr_Cleaner py_err_cleaner(false);
558 PyCallable pfunc = PyCallable::FindWithMemberFunction((PyObject *) implementor, method_name);
565 PyObject* py_return = Py_None;
569 lldb::SBEvent sb_event(event);
571 PyObject *py_obj_event = SBTypeToSWIGWrapper(sb_event);
573 py_return = pfunc(py_obj_event);
580 if (PyErr_Occurred())
583 printf ("Return value was neither false nor true for call to %s.\n", method_name);
588 if (py_return == Py_True)
590 else if (py_return == Py_False)
594 // Somebody returned the wrong thing...
596 printf ("Wrong return value type for call to %s.\n", method_name);
600 Py_XDECREF(py_return);
605 // wrapper that calls an optional instance member of an object taking no arguments
607 LLDBSwigPython_CallOptionalMember
611 PyObject* ret_if_not_found = Py_None,
612 bool* was_found = NULL
615 PyErr_Cleaner py_err_cleaner(false);
617 PyCallable pfunc = PyCallable::FindWithMemberFunction(self,callee_name);
623 Py_XINCREF(ret_if_not_found);
624 return ret_if_not_found;
630 PyObject* py_return = pfunc();
635 LLDBSwigPython_CalculateNumChildren
637 PyObject *implementor
640 size_t ret_val = UINT32_MAX;
641 bool int_match = false;
643 static char callee_name[] = "num_children";
645 PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name, NULL);
650 // PyInt_* are not available for Python 3 and above.
651 #if PY_MAJOR_VERSION < 3
652 if (PyInt_Check (py_return))
655 ret_val = static_cast<size_t> (PyInt_AsLong (py_return));
659 // We want to check for PyLong only if the return value did not
660 // match PyInt. This is because we do not want to call PyLong_Check if
661 // PyInt_Check returns true but PyInt_AsLong generates an error.
662 if (!int_match && PyLong_Check (py_return))
664 #if PY_MAJOR_VERSION < 3
665 ret_val = static_cast<size_t> (PyLong_AsUnsignedLong (py_return));
667 // PyLong_AsSize_t is available only for Python 3 and above.
668 ret_val = PyLong_AsSize_t (py_return);
672 Py_XDECREF(py_return);
674 if (PyErr_Occurred())
684 LLDBSwigPython_GetChildAtIndex
686 PyObject *implementor,
690 PyErr_Cleaner py_err_cleaner(true);
692 PyCallable pfunc = PyCallable::FindWithMemberFunction(implementor,"get_child_at_index");
697 PyObject *py_return = NULL;
698 py_return = pfunc(idx);
700 if (py_return == NULL || py_return == Py_None)
702 Py_XDECREF(py_return);
706 lldb::SBValue* sbvalue_ptr = NULL;
708 if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
710 Py_XDECREF(py_return);
714 if (sbvalue_ptr == NULL)
721 LLDBSwigPython_GetIndexOfChildWithName
723 PyObject *implementor,
724 const char* child_name
727 PyErr_Cleaner py_err_cleaner(true);
729 PyCallable pfunc = PyCallable::FindWithMemberFunction(implementor,"get_child_index");
734 PyObject *py_return = NULL;
735 py_return = pfunc(child_name);
737 if (py_return == NULL || py_return == Py_None)
739 Py_XDECREF(py_return);
743 long retval = PyInt_AsLong(py_return);
744 Py_XDECREF(py_return);
747 return (uint32_t)retval;
753 LLDBSwigPython_UpdateSynthProviderInstance
755 PyObject *implementor
758 bool ret_val = false;
760 static char callee_name[] = "update";
762 PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name);
764 if (py_return == Py_True)
767 Py_XDECREF(py_return);
773 LLDBSwigPython_MightHaveChildrenSynthProviderInstance
775 PyObject *implementor
778 bool ret_val = false;
780 static char callee_name[] = "has_children";
782 PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name, Py_True);
784 if (py_return == Py_True)
787 Py_XDECREF(py_return);
793 LLDBSwigPython_GetValueSynthProviderInstance
795 PyObject *implementor
798 PyObject* ret_val = nullptr;
800 static char callee_name[] = "get_value";
802 PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name, Py_None);
804 if (py_return == Py_None || py_return == nullptr)
807 lldb::SBValue* sbvalue_ptr = NULL;
809 if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
811 else if (sbvalue_ptr == NULL)
816 Py_XDECREF(py_return);
821 LLDBSWIGPython_CastPyObjectToSBValue
826 lldb::SBValue* sb_ptr = NULL;
828 int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0);
830 if (valid_cast == -1)
836 // Currently, SBCommandReturnObjectReleaser wraps a unique pointer to an
837 // lldb_private::CommandReturnObject. This means that the destructor for the
838 // SB object will deallocate its contained CommandReturnObject. Because that
839 // object is used as the real return object for Python-based commands, we want
840 // it to stay around. Thus, we release the unique pointer before returning from
841 // LLDBSwigPythonCallCommand, and to guarantee that the release will occur no
842 // matter how we exit from the function, we have a releaser object whose
843 // destructor does the right thing for us
844 class SBCommandReturnObjectReleaser
847 SBCommandReturnObjectReleaser (lldb::SBCommandReturnObject &obj) :
848 m_command_return_object_ref (obj)
852 ~SBCommandReturnObjectReleaser ()
854 m_command_return_object_ref.Release();
857 lldb::SBCommandReturnObject &m_command_return_object_ref;
861 LLDBSwigPythonCallCommand
863 const char *python_function_name,
864 const char *session_dictionary_name,
865 lldb::DebuggerSP& debugger,
867 lldb_private::CommandReturnObject& cmd_retobj,
868 lldb::ExecutionContextRefSP exe_ctx_ref_sp
872 lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj);
873 SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb);
874 lldb::SBDebugger debugger_sb(debugger);
875 lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp);
880 PyErr_Cleaner py_err_cleaner(true);
881 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
886 PyObject* session_dict = NULL;
887 // pass the pointer-to cmd_retobj_sb or watch the underlying object disappear from under you
888 // see comment above for SBCommandReturnObjectReleaser for further details
889 PyObject* pvalue = NULL;
891 PyCallable::argc argc = pfunc.GetNumArguments();
892 if (argc.num_args == 5 || argc.varargs == true)
893 pvalue = pfunc(debugger_sb, args, exe_ctx_sb, &cmd_retobj_sb, session_dict = FindSessionDictionary(session_dictionary_name));
895 pvalue = pfunc(debugger_sb, args, &cmd_retobj_sb, session_dict = FindSessionDictionary(session_dictionary_name));
897 Py_XINCREF (session_dict);
907 LLDBSwigPythonCallCommandObject
909 PyObject *implementor,
910 lldb::DebuggerSP& debugger,
912 lldb_private::CommandReturnObject& cmd_retobj,
913 lldb::ExecutionContextRefSP exe_ctx_ref_sp
917 lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj);
918 SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb);
919 lldb::SBDebugger debugger_sb(debugger);
920 lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp);
922 PyErr_Cleaner py_err_cleaner(true);
924 PyCallable pfunc = PyCallable::FindWithMemberFunction(implementor,"__call__");
929 // pass the pointer-to cmd_retobj_sb or watch the underlying object disappear from under you
930 // see comment above for SBCommandReturnObjectReleaser for further details
931 PyObject* pvalue = NULL;
933 pvalue = pfunc(debugger_sb, args, exe_ctx_sb, &cmd_retobj_sb);
941 LLDBSWIGPythonCreateOSPlugin
943 const char *python_class_name,
944 const char *session_dictionary_name,
945 const lldb::ProcessSP& process_sp
948 PyObject* retval = NULL;
950 if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
953 // I do not want the SBProcess to be deallocated when going out of scope because python
954 // has ownership of it and will manage memory for this object by itself
955 lldb::SBProcess *process_sb = new lldb::SBProcess(process_sp);
957 PyObject *SBProc_PyObj = SBTypeToSWIGWrapper(process_sb);
959 if (SBProc_PyObj == NULL)
963 PyErr_Cleaner py_err_cleaner(true);
965 PyCallable pfunc = PyCallable::FindWithFunctionName(python_class_name,session_dictionary_name);
970 Py_INCREF(SBProc_PyObj);
972 PyObject* session_dict = NULL;
973 session_dict = session_dict = FindSessionDictionary(session_dictionary_name);
974 retval = pfunc(SBProc_PyObj);
976 Py_XINCREF (session_dict);
988 LLDBSWIGPython_GetDynamicSetting (void* module, const char* setting, const lldb::TargetSP& target_sp)
991 if (!module || !setting)
994 lldb::SBTarget target_sb(target_sp);
996 PyObject *pvalue = NULL;
999 PyErr_Cleaner py_err_cleaner(true);
1000 PyCallable pfunc = PyCallable::FindWithFunctionName("get_dynamic_setting",(PyObject *)module);
1005 pvalue = pfunc(target_sb, setting);
1012 LLDBSWIGPythonRunScriptKeywordProcess
1013 (const char* python_function_name,
1014 const char* session_dictionary_name,
1015 lldb::ProcessSP& process,
1016 std::string& output)
1019 bool retval = false;
1021 if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
1024 lldb::SBProcess process_sb(process);
1027 PyErr_Cleaner py_err_cleaner(true);
1029 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
1034 PyObject* session_dict = NULL;
1035 PyObject* pvalue = NULL;
1036 pvalue = pfunc(process_sb, session_dict = FindSessionDictionary(session_dictionary_name));
1038 Py_XINCREF (session_dict);
1040 if (PyObjectToString(pvalue,output))
1050 LLDBSWIGPythonRunScriptKeywordThread
1051 (const char* python_function_name,
1052 const char* session_dictionary_name,
1053 lldb::ThreadSP& thread,
1054 std::string& output)
1057 bool retval = false;
1059 if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
1062 lldb::SBThread thread_sb(thread);
1065 PyErr_Cleaner py_err_cleaner(true);
1067 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
1072 PyObject* session_dict = NULL;
1073 PyObject* pvalue = NULL;
1074 pvalue = pfunc(thread_sb, session_dict = FindSessionDictionary(session_dictionary_name));
1076 Py_XINCREF (session_dict);
1078 if (PyObjectToString(pvalue,output))
1088 LLDBSWIGPythonRunScriptKeywordTarget
1089 (const char* python_function_name,
1090 const char* session_dictionary_name,
1091 lldb::TargetSP& target,
1092 std::string& output)
1095 bool retval = false;
1097 if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
1100 lldb::SBTarget target_sb(target);
1103 PyErr_Cleaner py_err_cleaner(true);
1105 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
1110 PyObject* session_dict = NULL;
1111 PyObject* pvalue = NULL;
1112 pvalue = pfunc(target_sb, session_dict = FindSessionDictionary(session_dictionary_name));
1114 Py_XINCREF (session_dict);
1116 if (PyObjectToString(pvalue,output))
1126 LLDBSWIGPythonRunScriptKeywordFrame
1127 (const char* python_function_name,
1128 const char* session_dictionary_name,
1129 lldb::StackFrameSP& frame,
1130 std::string& output)
1133 bool retval = false;
1135 if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
1138 lldb::SBFrame frame_sb(frame);
1141 PyErr_Cleaner py_err_cleaner(true);
1143 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
1148 PyObject* session_dict = NULL;
1149 PyObject* pvalue = NULL;
1150 pvalue = pfunc(frame_sb, session_dict = FindSessionDictionary(session_dictionary_name));
1152 Py_XINCREF (session_dict);
1154 if (PyObjectToString(pvalue,output))
1164 LLDBSWIGPythonRunScriptKeywordValue
1165 (const char* python_function_name,
1166 const char* session_dictionary_name,
1167 lldb::ValueObjectSP& value,
1168 std::string& output)
1171 bool retval = false;
1173 if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
1176 lldb::SBValue value_sb(value);
1179 PyErr_Cleaner py_err_cleaner(true);
1181 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
1186 PyObject* session_dict = NULL;
1187 PyObject* pvalue = NULL;
1188 pvalue = pfunc(value_sb, session_dict = FindSessionDictionary(session_dictionary_name));
1190 Py_XINCREF (session_dict);
1192 if (PyObjectToString(pvalue,output))
1202 LLDBSwigPythonCallModuleInit
1204 const char *python_module_name,
1205 const char *session_dictionary_name,
1206 lldb::DebuggerSP& debugger
1209 bool retval = false;
1211 lldb::SBDebugger debugger_sb(debugger);
1213 std::string python_function_name_string = python_module_name;
1214 python_function_name_string += ".__lldb_init_module";
1215 const char* python_function_name = python_function_name_string.c_str();
1218 PyErr_Cleaner py_err_cleaner(true);
1220 PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
1225 PyObject* session_dict = NULL;
1226 PyObject* pvalue = NULL;
1227 pvalue = pfunc(debugger_sb, session_dict = FindSessionDictionary(session_dictionary_name));
1229 Py_XINCREF (session_dict);
1242 // Forward declaration to be inserted at the start of LLDBWrapPython.h
1243 #include "lldb/API/SBDebugger.h"
1244 #include "lldb/API/SBValue.h"
1246 SWIGEXPORT lldb::ValueObjectSP
1247 LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data)
1249 lldb::ValueObjectSP valobj_sp;
1252 lldb::SBValue* sb_ptr = (lldb::SBValue *)data;
1253 valobj_sp = sb_ptr->GetSP();
1262 void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton);
1272 // For the LogOutputCallback functions
1273 void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton) {
1274 if (baton != Py_None) {
1275 SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1276 PyObject_CallFunction(reinterpret_cast<PyObject*>(baton), const_cast<char*>("s"), str);
1277 SWIG_PYTHON_THREAD_END_BLOCK;