[Lldb-commits] [lldb] r185560 - Revert commits that cause broken builds on GCC buildbots

Enrico Granata egranata at apple.com
Mon Jul 8 10:27:38 PDT 2013


Reverting was definitely the right thing to do as I was out on vacation throughout last week.
I am not sure why the change that defines SBCommandReturnObject::SetError() also had to be reverted, but I assume it just died its fiery death along with the rest of the patch

Since a lot of this code is SWIG boilerplate, I will see what can be done to fix the scoping issue - hopefully it can be done

Enrico Granata
📩 egranata@.com
☎️ 27683

On Jul 3, 2013, at 10:58 AM, Daniel Malea <daniel.malea at intel.com> wrote:

> Author: dmalea
> Date: Wed Jul  3 12:58:31 2013
> New Revision: 185560
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=185560&view=rev
> Log:
> Revert commits that cause broken builds on GCC buildbots
> - build fails due to PyCallable template definition inside an extern "C" scope
> 
> This commit reverts 185240, 184893 and 184608.
> 
> 
> Modified:
>    lldb/trunk/include/lldb/API/SBCommandReturnObject.h
>    lldb/trunk/include/lldb/API/SBError.h
>    lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
>    lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
>    lldb/trunk/lldb.xcodeproj/project.pbxproj
>    lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
>    lldb/trunk/scripts/Python/python-swigsafecast.swig
>    lldb/trunk/scripts/Python/python-wrapper.swig
>    lldb/trunk/source/API/SBCommandReturnObject.cpp
>    lldb/trunk/source/Commands/CommandObjectCommands.cpp
>    lldb/trunk/source/Interpreter/CommandReturnObject.cpp
>    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
>    lldb/trunk/test/functionalities/command_script/welcome.py
>    lldb/trunk/test/help/TestHelp.py
> 
> Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original)
> +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Wed Jul  3 12:58:31 2013
> @@ -98,13 +98,6 @@ public:
>     const char *
>     GetError (bool only_if_no_immediate);
> 
> -    void
> -    SetError (lldb::SBError &error,
> -              const char *fallback_error_cstr = NULL);
> -    
> -    void
> -    SetError (const char* error_cstr);
> -    
> protected:
>     friend class SBCommandInterpreter;
>     friend class SBOptions;
> 
> Modified: lldb/trunk/include/lldb/API/SBError.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/API/SBError.h (original)
> +++ lldb/trunk/include/lldb/API/SBError.h Wed Jul  3 12:58:31 2013
> @@ -66,7 +66,6 @@ public:
> 
> protected:
> 
> -    friend class SBCommandReturnObject;
>     friend class SBData;
>     friend class SBDebugger;
>     friend class SBCommunication;
> 
> Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original)
> +++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Wed Jul  3 12:58:31 2013
> @@ -143,11 +143,8 @@ public:
> 
>     void
>     SetError (const Error &error, 
> -              const char *fallback_error_cstr = NULL);
> +              const char *fallback_error_cstr);
> 
> -    void
> -    SetError (const char *error_cstr);
> -    
>     lldb::ReturnStatus
>     GetStatus();
> 
> 
> Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
> +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Wed Jul  3 12:58:31 2013
> @@ -120,6 +120,7 @@ public:
>                                                                      const char *session_dictionary_name,
>                                                                      lldb::DebuggerSP& debugger,
>                                                                      const char* args,
> +                                                                     std::string& err_msg,
>                                                                      lldb_private::CommandReturnObject& cmd_retobj);
> 
>     typedef bool           (*SWIGPythonCallModuleInit)              (const char *python_module_name,
> 
> Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
> +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jul  3 12:58:31 2013
> @@ -1545,7 +1545,7 @@
> 		69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = "<group>"; };
> 		69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = "<group>"; };
> 		69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = "<group>"; };
> -		94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; path = "python-wrapper.swig"; sourceTree = "<group>"; };
> +		94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-wrapper.swig"; sourceTree = "<group>"; };
> 		94005E0513F45A1B001EF42D /* embedded_interpreter.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = embedded_interpreter.py; path = source/Interpreter/embedded_interpreter.py; sourceTree = "<group>"; };
> 		94031A9B13CF484600DCFF3C /* InputReaderEZ.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InputReaderEZ.h; path = include/lldb/Core/InputReaderEZ.h; sourceTree = "<group>"; };
> 		94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReaderEZ.cpp; path = source/Core/InputReaderEZ.cpp; sourceTree = "<group>"; };
> @@ -1557,7 +1557,7 @@
> 		944372DB171F6B4300E57C32 /* RegisterContextDummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDummy.h; path = Utility/RegisterContextDummy.h; sourceTree = "<group>"; };
> 		9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
> 		9443B121140C18C10013457C /* SBData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBData.cpp; path = source/API/SBData.cpp; sourceTree = "<group>"; };
> -		944DC3481774C99000D7D884 /* python-swigsafecast.swig */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; path = "python-swigsafecast.swig"; sourceTree = "<group>"; };
> +		944DC3481774C99000D7D884 /* python-swigsafecast.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-swigsafecast.swig"; sourceTree = "<group>"; };
> 		9452573616262CD000325455 /* SBDeclaration.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBDeclaration.i; sourceTree = "<group>"; };
> 		9452573816262CEF00325455 /* SBDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBDeclaration.h; path = include/lldb/API/SBDeclaration.h; sourceTree = "<group>"; };
> 		9452573916262D0200325455 /* SBDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBDeclaration.cpp; path = source/API/SBDeclaration.cpp; sourceTree = "<group>"; };
> @@ -1628,7 +1628,7 @@
> 		94D6A0A816CEB55F00833B6E /* NSDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSDictionary.cpp; path = source/DataFormatters/NSDictionary.cpp; sourceTree = "<group>"; };
> 		94D6A0A916CEB55F00833B6E /* NSSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSSet.cpp; path = source/DataFormatters/NSSet.cpp; sourceTree = "<group>"; };
> 		94E367CC140C4EC4001C7A5A /* modify-python-lldb.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = "modify-python-lldb.py"; sourceTree = "<group>"; };
> -		94E367CE140C4EEA001C7A5A /* python-typemaps.swig */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; path = "python-typemaps.swig"; sourceTree = "<group>"; };
> +		94E367CE140C4EEA001C7A5A /* python-typemaps.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-typemaps.swig"; sourceTree = "<group>"; };
> 		94EA1D5A15E6C99B00D4171A /* PythonDataObjects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PythonDataObjects.h; path = include/lldb/Interpreter/PythonDataObjects.h; sourceTree = "<group>"; };
> 		94EA1D5B15E6C9B400D4171A /* PythonDataObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonDataObjects.cpp; path = source/Interpreter/PythonDataObjects.cpp; sourceTree = "<group>"; };
> 		94EBAC8313D9EE26009BA64E /* PythonPointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PythonPointer.h; path = include/lldb/Utility/PythonPointer.h; sourceTree = "<group>"; };
> @@ -1658,7 +1658,7 @@
> 		9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpointCommand.cpp; path = source/Commands/CommandObjectBreakpointCommand.cpp; sourceTree = "<group>"; };
> 		9A4633DA11F65D8600955CE1 /* UserSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserSettingsController.h; path = include/lldb/Core/UserSettingsController.h; sourceTree = "<group>"; };
> 		9A4633DC11F65D9A00955CE1 /* UserSettingsController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserSettingsController.cpp; path = source/Core/UserSettingsController.cpp; sourceTree = "<group>"; };
> -		9A48A3A7124AAA5A00922451 /* python-extensions.swig */ = {isa = PBXFileReference; explicitFileType = text.script.python; fileEncoding = 4; path = "python-extensions.swig"; sourceTree = "<group>"; };
> +		9A48A3A7124AAA5A00922451 /* python-extensions.swig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "python-extensions.swig"; sourceTree = "<group>"; };
> 		9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamAsynchronousIO.cpp; path = source/Core/StreamAsynchronousIO.cpp; sourceTree = "<group>"; };
> 		9A4F35111368A54100823F52 /* StreamAsynchronousIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamAsynchronousIO.h; path = include/lldb/Core/StreamAsynchronousIO.h; sourceTree = "<group>"; };
> 		9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFrame.cpp; path = source/API/SBFrame.cpp; sourceTree = "<group>"; };
> 
> Modified: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i (original)
> +++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i Wed Jul  3 12:58:31 2013
> @@ -58,14 +58,7 @@ public:
> 
>     void
>     SetStatus (lldb::ReturnStatus status);
> -    
> -    void
> -    SetError (lldb::SBError &error,
> -              const char *fallback_error_cstr = NULL);
> 
> -    void
> -    SetError (const char *error_cstr);
> -    
>     lldb::ReturnStatus
>     GetStatus();
> 
> 
> Modified: lldb/trunk/scripts/Python/python-swigsafecast.swig
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-swigsafecast.swig?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/scripts/Python/python-swigsafecast.swig (original)
> +++ lldb/trunk/scripts/Python/python-swigsafecast.swig Wed Jul  3 12:58:31 2013
> @@ -1,3 +1,7 @@
> +#ifndef __cplusplus
> +#error needs C++ to build these
> +#endif
> +
> // leaving this undefined ensures we will get a linker error if we try to use SBTypeToSWIGWrapper()
> // for a type for which we did not specialze this function
> template <typename SBClass>
> @@ -11,38 +15,6 @@ SBTypeToSWIGWrapper (SBClass& sb_object)
>     return SBTypeToSWIGWrapper(&sb_object);
> }
> 
> -template <typename SBClass>
> -PyObject*
> -SBTypeToSWIGWrapper (const SBClass& sb_object)
> -{
> -    return SBTypeToSWIGWrapper(&sb_object);
> -}
> -
> -template <>
> -PyObject*
> -SBTypeToSWIGWrapper (PyObject* py_object)
> -{
> -    return py_object;
> -}
> -
> -template <>
> -PyObject*
> -SBTypeToSWIGWrapper (const char* c_str)
> -{
> -    if (c_str)
> -        return PyString_FromString(c_str);
> -    return NULL;
> -}
> -
> -template <>
> -PyObject*
> -SBTypeToSWIGWrapper (unsigned int* c_int)
> -{
> -    if (!c_int)
> -        return NULL;
> -    return PyInt_FromLong(*c_int);
> -}
> -
> template <>
> PyObject*
> SBTypeToSWIGWrapper (lldb::SBProcess* process_sb)
> 
> Modified: lldb/trunk/scripts/Python/python-wrapper.swig
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/scripts/Python/python-wrapper.swig (original)
> +++ lldb/trunk/scripts/Python/python-wrapper.swig Wed Jul  3 12:58:31 2013
> @@ -103,97 +103,6 @@ FindSessionDictionary(const char *sessio
>     return ResolvePythonName(session_dictionary_name, NULL);
> }
> 
> -class PyCallable
> -{
> -public:
> -
> -    operator
> -    bool ()
> -    {
> -        return m_callable != NULL;
> -    }
> -
> -    template<typename ...Args>
> -    PyObject*
> -    operator () (Args... args)
> -    {
> -        return (*this)({SBTypeToSWIGWrapper(args)...});
> -    }
> -    
> -    PyObject*
> -    operator () (std::initializer_list<PyObject*> args)
> -    {
> -        PyObject* retval = NULL;
> -        PyObject* pargs = PyTuple_New (args.size());
> -        if (pargs == NULL)
> -        {
> -            if (PyErr_Occurred())
> -                PyErr_Clear();
> -            return retval;
> -        }
> -        size_t idx = 0;
> -        for (auto arg : args)
> -        {
> -            if (!arg)
> -                return retval;
> -            PyTuple_SetItem(pargs,idx,arg);
> -            idx++;
> -        }
> -        retval = PyObject_CallObject (m_callable, pargs);
> -        Py_XDECREF (pargs);
> -        return retval;
> -    }
> -    
> -    static PyCallable
> -    FindWithPythonObject (PyObject* pfunc)
> -    {
> -        return PyCallable(pfunc);
> -    }
> -    
> -    static PyCallable
> -    FindWithFunctionName (const char *python_function_name,
> -                          const char *session_dictionary_name)
> -    {
> -        if (!python_function_name || !session_dictionary_name)
> -            return PyCallable();
> -        if ( (python_function_name[0] == 0) || (session_dictionary_name[0] == 0) )
> -            return PyCallable();
> -        return FindWithFunctionName(python_function_name,FindSessionDictionary (session_dictionary_name));
> -    }
> -    
> -    static PyCallable
> -    FindWithFunctionName (const char *python_function_name,
> -                          PyObject *session_dict)
> -    {
> -        if (!python_function_name || !session_dict)
> -            return PyCallable();
> -        if ( (python_function_name[0] == 0))
> -            return PyCallable();
> -        return PyCallable(ResolvePythonName (python_function_name, session_dict));
> -    }
> -
> -    static PyCallable
> -    FindWithMemberFunction (PyObject *self,
> -                            const char *python_function_name)
> -    {
> -        if (self == NULL || self == Py_None)
> -            return PyCallable();
> -        if (!python_function_name || (python_function_name[0] == 0))
> -            return PyCallable();
> -        return PyCallable(PyObject_GetAttrString(self, python_function_name));
> -    }
> -
> -private:
> -    PyObject* m_callable;
> -    
> -    PyCallable (PyObject *callable = NULL) :
> -    m_callable(callable)
> -    {
> -        if (m_callable && PyCallable_Check(m_callable) == false)
> -            m_callable = NULL;
> -    }
> -};
> -
> // This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
> // and is used when a script command is attached to a breakpoint for execution.
> 
> @@ -210,27 +119,70 @@ LLDBSwigPythonBreakpointCallbackFunction
>     lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
> 
>     bool stop_at_breakpoint = true;
> -
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return stop_at_breakpoint;
> -        
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(sb_frame, sb_bp_loc, session_dict = FindSessionDictionary(session_dictionary_name));
> -        
> -        Py_XINCREF (session_dict);
> +    PyObject *Frame_PyObj = SBTypeToSWIGWrapper(sb_frame);
> +    PyObject *Bp_Loc_PyObj = SBTypeToSWIGWrapper(sb_bp_loc);
> +    
> +    if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL)
> +        return stop_at_breakpoint;
> 
> -        if (pvalue == Py_False)
> -            stop_at_breakpoint = false;
> +    if (!python_function_name || !session_dictionary_name)
> +        return stop_at_breakpoint;
> 
> -        Py_XDECREF (pvalue);
> -    }
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> 
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> +    if (session_dict != NULL)
> +    {
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> +        if (pfunc != NULL)
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (3);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return stop_at_breakpoint;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, Frame_PyObj);  // This "steals" a reference to Frame_PyObj
> +                PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj
> +                PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (pvalue != NULL)
> +                {
> +                    // be very conservative here and only refuse to stop if the user
> +                    // actually returned False - anything else, just stop
> +                    if (pvalue == Py_False)
> +                        stop_at_breakpoint = false;
> +                    Py_XDECREF (pvalue);
> +                }
> +                else if (PyErr_Occurred ())
> +                {
> +                    PyErr_Clear();
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Clear();
> +            }
> +        }
> +        else if (PyErr_Occurred())
> +        {
> +            PyErr_Clear();
> +        }
> +    }
> +    else if (PyErr_Occurred ())
> +    {
> +        PyErr_Clear ();
> +    }
>     return stop_at_breakpoint;
> }
> 
> @@ -250,55 +202,67 @@ LLDBSwigPythonWatchpointCallbackFunction
>     lldb::SBWatchpoint sb_wp(wp_sp);
> 
>     bool stop_at_watchpoint = true;
> +    PyObject *Frame_PyObj = SBTypeToSWIGWrapper(sb_frame);
> +    PyObject *Wp_PyObj = SBTypeToSWIGWrapper(sb_wp);
> 
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return stop_at_watchpoint;
> +    if (Frame_PyObj == NULL || Wp_PyObj == NULL)
> +        return stop_at_watchpoint;
> 
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(sb_frame, sb_wp, session_dict = FindSessionDictionary(session_dictionary_name));
> -        
> -        Py_XINCREF (session_dict);
> -        
> -        if (pvalue == Py_False)
> -            stop_at_watchpoint = false;
> -        
> -        Py_XDECREF (pvalue);
> -    }
> -    
> -    return stop_at_watchpoint;
> -}
> +    if (!python_function_name || !session_dictionary_name)
> +        return stop_at_watchpoint;
> 
> -bool
> -PyObjectToString (PyObject* object,
> -                  std::string& retval)
> -{
> -    retval.clear();
> -    bool was_ok = false;
> -    if (object != NULL && object != Py_None)
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> +    if (session_dict != NULL)
>     {
> -        if (PyString_Check(object))
> -        {
> -            retval.assign(PyString_AsString(object));
> -            was_ok = true;
> -        }
> -        else
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> +        if (pfunc != NULL)
>         {
> -            PyObject* value_as_string = PyObject_Str(object);
> -            if (value_as_string && value_as_string != Py_None && PyString_Check(value_as_string))
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (3);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return stop_at_watchpoint;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, Frame_PyObj);  // This "steals" a reference to Frame_PyObj
> +                PyTuple_SetItem (pargs, 1, Wp_PyObj);     // This "steals" a reference to Wp_PyObj
> +                PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (pvalue != NULL)
> +                {
> +                    Py_XDECREF (pvalue);
> +                }
> +                else if (PyErr_Occurred ())
> +                {
> +                    PyErr_Clear();
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
>             {
> -                retval.assign(PyString_AsString(value_as_string));
> -                was_ok = true;
> +                PyErr_Clear();
>             }
> -            Py_XDECREF(value_as_string);
>         }
> +        else if (PyErr_Occurred())
> +        {
> +            PyErr_Clear();
> +        }
> +    }
> +    else if (PyErr_Occurred ())
> +    {
> +        PyErr_Clear ();
>     }
> -    return was_ok;
> +    return stop_at_watchpoint;
> }
> 
> SWIGEXPORT bool
> @@ -315,18 +279,23 @@ LLDBSwigPythonCallTypeScript
> 
>     retval.clear();
> 
> +    PyObject *ValObj_PyObj = SBTypeToSWIGWrapper(sb_value);
> +    
> +    if (ValObj_PyObj == NULL)
> +        return false;
> +        
>     if (!python_function_name || !session_dictionary)
>         return false;
> 
> -    PyObject *session_dict = (PyObject*)session_dictionary, *pfunc_impl = NULL, *pvalue = NULL;
> +    PyObject *session_dict = (PyObject*)session_dictionary, *pfunc = NULL, *pargs = NULL, *pvalue = NULL;
> 
>     if (pyfunct_wrapper && *pyfunct_wrapper && PyFunction_Check (*pyfunct_wrapper))
>     {
> -        pfunc_impl = (PyObject*)(*pyfunct_wrapper);
> -        if (pfunc_impl->ob_refcnt == 1)
> +        pfunc = (PyObject*)(*pyfunct_wrapper);
> +        if (pfunc->ob_refcnt == 1)
>         {
> -            Py_XDECREF(pfunc_impl);
> -            pfunc_impl = NULL;
> +            Py_XDECREF(pfunc);
> +            pfunc = NULL;
>         }
>     }
> 
> @@ -334,32 +303,41 @@ LLDBSwigPythonCallTypeScript
>     {
>         PyErr_Cleaner pyerr_cleanup(true);  // show Python errors
> 
> -        if (!pfunc_impl)
> +        if (!pfunc)
>         {
> -            pfunc_impl = ResolvePythonName (python_function_name, session_dict);
> -            if (!pfunc_impl || !PyCallable_Check (pfunc_impl))
> +            pfunc = ResolvePythonName (python_function_name, session_dict);
> +            if (!pfunc || !PyFunction_Check (pfunc))
>                 return false;
>             else
>             {
>                 if (pyfunct_wrapper)
> -                    *pyfunct_wrapper = pfunc_impl;
> +                    *pyfunct_wrapper = pfunc;
>             }
>         }
>         /*else
>             printf("caching works!!!!\n");*/
> 
> -        PyCallable pfunc = PyCallable::FindWithPythonObject(pfunc_impl);
> -        
> -        if (!pfunc)
> +        pargs = PyTuple_Pack(2, ValObj_PyObj, session_dict);
> +        if (pargs == NULL)
>             return false;
> 
> -        pvalue = pfunc(sb_value,session_dict);
> -
> -        Py_INCREF (session_dict);
> -        
> -        PyObjectToString(pvalue,retval);
> +        pvalue = PyObject_CallObject (pfunc, pargs);
> +        Py_XDECREF (pargs);
> 
> +        if (pvalue != NULL && pvalue != Py_None)
> +        {
> +            if (PyString_Check(pvalue))
> +                retval.assign(PyString_AsString(pvalue));
> +            else
> +            {
> +                PyObject* value_as_string = PyObject_Str(pvalue);
> +                if (value_as_string && value_as_string != Py_None && PyString_Check(value_as_string))
> +                    retval.assign(PyString_AsString(value_as_string));
> +                Py_XDECREF(value_as_string);
> +            }
> +        }
>         Py_XDECREF (pvalue);
> +        Py_INCREF (session_dict);
>     }
>     return true;
> }
> @@ -381,29 +359,81 @@ LLDBSwigPythonCreateSyntheticProvider
>     // has ownership of it and will manage memory for this object by itself
>     lldb::SBValue *sb_value = new lldb::SBValue(valobj_sp);
>     sb_value->SetPreferSyntheticValue(false);
> +
>     PyObject *ValObj_PyObj = SBTypeToSWIGWrapper(sb_value);
> 
>     if (ValObj_PyObj == NULL)
>         Py_RETURN_NONE;
> +
> +    const char* python_function_name = python_class_name;
> +
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pvalue;
> 
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> +    if (session_dict != NULL)
>     {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_class_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> -        
> -        Py_INCREF(ValObj_PyObj);
> -        
> -        PyObject* session_dict = NULL;
> -        retval = pfunc(ValObj_PyObj, session_dict = FindSessionDictionary(session_dictionary_name));
> -        
> -        Py_XINCREF (session_dict);
> -        
> -        Py_XINCREF(retval);
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> +        if (pfunc != NULL)
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                PyObject *argList = Py_BuildValue("SS", ValObj_PyObj, session_dict);
> +
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                    return retval;
> +                }
> +
> +                if (argList == NULL)
> +                {
> +                    return retval;
> +                }
> +
> +                Py_INCREF(ValObj_PyObj);
> +
> +                pvalue = PyObject_CallObject(pfunc, argList);
> +
> +                Py_XDECREF(argList);
> +
> +                if (pvalue != NULL)
> +                {
> +                    if (pvalue != Py_None)
> +                        retval = pvalue;
> +                    else
> +                    {
> +                        retval = Py_None;
> +                        Py_INCREF(retval);
> +                    }
> +                }
> +                else if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
> +        else if (PyErr_Occurred())
> +        {
> +            PyErr_Print();
> +            PyErr_Clear();
> +        }
> +    }
> +    else if (PyErr_Occurred ())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear ();
>     }
> -    
>     if (retval)
>         return retval;
>     else
> @@ -420,22 +450,64 @@ LLDBSwigPython_CallOptionalMember
>     bool* was_found = NULL
> )
> {
> -    PyErr_Cleaner py_err_cleaner(false);
> -    
> -    PyCallable pfunc = PyCallable::FindWithMemberFunction(self,callee_name);
> -    
> -    if (!pfunc)
> +    if (self == NULL || self == Py_None)
>     {
>         if (was_found)
>             *was_found = false;
>         Py_XINCREF(ret_if_not_found);
>         return ret_if_not_found;
>     }
> -    
> +
> +    PyObject* pmeth  = PyObject_GetAttrString(self, callee_name);
> +
> +    if (PyErr_Occurred())
> +    {
> +        PyErr_Clear();
> +    }
> +
> +    if (pmeth == NULL || pmeth == Py_None)
> +    {
> +        if (was_found)
> +            *was_found = false;
> +        Py_XDECREF(pmeth);
> +        Py_XINCREF(ret_if_not_found);
> +        return ret_if_not_found;
> +    }
> +
> +    if (PyCallable_Check(pmeth) == 0)
> +    {
> +        if (PyErr_Occurred())
> +        {
> +            PyErr_Clear();
> +        }
> +
> +        Py_XDECREF(pmeth);
> +        if (was_found)
> +            *was_found = false;
> +        Py_XINCREF(ret_if_not_found);
> +        return ret_if_not_found;
> +    }
> +
>     if (was_found)
>         *was_found = true;
> +
> +    if (PyErr_Occurred())
> +    {
> +        PyErr_Clear();
> +    }
> +
> +    Py_XDECREF(pmeth);
> +
> +    // right now we know this function exists and is callable..
> +    PyObject* py_return = PyObject_CallMethod(self, callee_name, NULL);
> +    
> +    // if it fails, print the error but otherwise go on
> +    if (PyErr_Occurred())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear();
> +    }
> 
> -    PyObject* py_return = pfunc();
>     return py_return;
> }
> 
> @@ -475,15 +547,18 @@ LLDBSwigPython_GetChildAtIndex
>     uint32_t idx
> )
> {
> -    PyErr_Cleaner py_err_cleaner(true);
> -    
> -    PyCallable pfunc = PyCallable::FindWithMemberFunction(implementor,"get_child_at_index");
> -    
> -    if (!pfunc)
> +
> +    static char callee_name[] = "get_child_at_index";
> +    static char param_format[] = "i";
> +
> +    if (implementor == NULL || implementor == Py_None)
>         return NULL;
> -    
> -    PyObject *py_return = NULL;
> -    py_return = pfunc(idx);
> +    PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, idx);
> +    if (PyErr_Occurred())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear();
> +    }
> 
>     if (py_return == NULL || py_return == Py_None)
>     {
> @@ -492,7 +567,7 @@ LLDBSwigPython_GetChildAtIndex
>     }
> 
>     lldb::SBValue* sbvalue_ptr = NULL;
> -    
> +
>     if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
>     {
>         Py_XDECREF(py_return);
> @@ -501,8 +576,8 @@ LLDBSwigPython_GetChildAtIndex
> 
>     if (sbvalue_ptr == NULL)
>         return NULL;
> -    
> -    return py_return;    
> +
> +    return py_return;
> }
> 
> SWIGEXPORT int
> @@ -512,29 +587,33 @@ LLDBSwigPython_GetIndexOfChildWithName
>     const char* child_name
> )
> {
> -    PyErr_Cleaner py_err_cleaner(true);
> -    
> -    PyCallable pfunc = PyCallable::FindWithMemberFunction(implementor,"get_child_index");
> -    
> -    if (!pfunc)
> -        return UINT32_MAX;
> -    
> -    PyObject *py_return = NULL;
> -    py_return = pfunc(child_name);
> +    static char callee_name[] = "get_child_index";
> +    static char param_format[] = "s";
> +
> +    if (implementor == NULL || implementor == Py_None)
> +        return 0;
> +    PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, child_name);
> +    if (PyErr_Occurred())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear();
> +    }
> 
>     if (py_return == NULL || py_return == Py_None)
>     {
>         Py_XDECREF(py_return);
>         return UINT32_MAX;
>     }
> -    
>     long retval = PyInt_AsLong(py_return);
>     Py_XDECREF(py_return);
> -
>     if (retval >= 0)
>         return (uint32_t)retval;
> -    
> -    return UINT32_MAX;
> +    if (PyErr_Occurred())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear();
> +    }
> +    return 0;
> }
> 
> SWIGEXPORT bool
> @@ -624,6 +703,7 @@ LLDBSwigPythonCallCommand
>     const char *session_dictionary_name,
>     lldb::DebuggerSP& debugger,
>     const char* args,
> +    std::string& err_msg,
>     lldb_private::CommandReturnObject& cmd_retobj
> )
> {
> @@ -634,25 +714,86 @@ LLDBSwigPythonCallCommand
> 
>     bool retval = false;
> 
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> +    PyObject *DebuggerObj_PyObj = SBTypeToSWIGWrapper(debugger_sb);
> +    PyObject *CmdRetObj_PyObj = SBTypeToSWIGWrapper(cmd_retobj_sb);
> 
> -        PyObject* session_dict = NULL;
> -        // pass the pointer-to cmd_retobj_sb or watch the underlying object disappear from under you
> -        // see comment above for SBCommandReturnObjectReleaser for further details
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(debugger_sb, args, &cmd_retobj_sb, session_dict = FindSessionDictionary(session_dictionary_name));
> -        
> -        Py_XINCREF (session_dict);
> -        Py_XDECREF (pvalue);
> +    if (DebuggerObj_PyObj == NULL)
> +        return retval;
> 
> -        retval = true;
> -    }
> +    if (CmdRetObj_PyObj == NULL)
> +        return retval;
> +
> +    if (!python_function_name || !session_dictionary_name)
> +        return retval;
> +
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> 
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> +    if (session_dict != NULL)
> +    {
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> +        if (pfunc != NULL)
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (4);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return retval;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj);  // This "steals" a reference to DebuggerObj_PyObj
> +                PyTuple_SetItem (pargs, 1, PyString_FromString(args));
> +                PyTuple_SetItem (pargs, 2, CmdRetObj_PyObj);  // This "steals" a reference to CmdRetObj_PyObj
> +                PyTuple_SetItem (pargs, 3, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (pvalue != NULL)
> +                {
> +                    if (pvalue == Py_None) // no error
> +                    {
> +                        err_msg.clear();
> +                        retval = true;
> +                    }
> +                    else
> +                    {
> +                        // return value is an error string
> +                        if (PyString_CheckExact(pvalue))
> +                            err_msg.assign(PyString_AsString(pvalue));
> +                        retval = false;
> +                    }
> +                    Py_XDECREF (pvalue);
> +                }
> +                else if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
> +        else if (PyErr_Occurred())
> +        {
> +            PyErr_Print();
> +            PyErr_Clear();
> +        }
> +    }
> +    else if (PyErr_Occurred ())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear ();
> +    }
>     return retval;
> }
> 
> @@ -678,25 +819,75 @@ LLDBSWIGPythonCreateOSPlugin
>     if (SBProc_PyObj == NULL)
>         Py_RETURN_NONE;
> 
> +    const char* python_function_name = python_class_name;
> +
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> +    if (session_dict != NULL)
>     {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_class_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> -        
> -        Py_INCREF(SBProc_PyObj);
> -        
> -        PyObject* session_dict = NULL;
> -        session_dict = session_dict = FindSessionDictionary(session_dictionary_name);
> -        retval = pfunc(SBProc_PyObj);
> -        
> -        Py_XINCREF (session_dict);
> -        
> -        Py_XINCREF(retval);
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> +        if (pfunc != NULL)
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                PyObject *argList = Py_BuildValue("(O)", SBProc_PyObj);
> +
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                    return retval;
> +                }
> +
> +                if (argList == NULL)
> +                {
> +                    return retval;
> +                }
> +
> +                Py_INCREF(SBProc_PyObj);
> +
> +                pvalue = PyObject_CallObject(pfunc, argList);
> +
> +                Py_XDECREF(argList);
> +
> +                if (pvalue != NULL)
> +                {
> +                    if (pvalue != Py_None)
> +                        retval = pvalue;
> +                    else
> +                    {
> +                        retval = Py_None;
> +                        Py_INCREF(retval);
> +                    }
> +                }
> +                else if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
> +        else if (PyErr_Occurred())
> +        {
> +            PyErr_Print();
> +            PyErr_Clear();
> +        }
> +    }
> +    else if (PyErr_Occurred ())
> +    {
> +        PyErr_Print();
> +        PyErr_Clear ();
>     }
> -    
>     if (retval)
>         return retval;
>     else
> @@ -717,27 +908,75 @@ std::string& output)
>         return retval;
> 
>     lldb::SBProcess process_sb(process);
> +    PyObject *ProcessObj_PyObj = SBTypeToSWIGWrapper(process_sb);
> 
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> -        
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(process_sb, session_dict = FindSessionDictionary(session_dictionary_name));
> +    if (ProcessObj_PyObj == NULL)
> +        return retval;
> 
> -        Py_XINCREF (session_dict);
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> 
> -        if (PyObjectToString(pvalue,output))
> -            retval = true;
> +    if (session_dict != NULL)
> +    {
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> 
> -        Py_XDECREF(pvalue);
> +        if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
> +        {
> +            PyErr_Clear();
> +            return true;
> +        }
> +
> +        if (pfunc == NULL)
> +            return true;
> +        else
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (2);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return retval;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, ProcessObj_PyObj);  // This "steals" a reference to ProcessObj_PyObj
> +                PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                else
> +                {
> +                    if (PyString_Check(pvalue))
> +                    {
> +                        output.assign(PyString_AsString(pvalue));
> +                        retval = true;
> +                    }
> +                    else
> +                    {
> +                        output.clear();
> +                        retval = false;
> +                    }
> +                    Py_XDECREF (pvalue);
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
>     }
> -    
>     return retval;
> }
> 
> @@ -755,27 +994,75 @@ std::string& output)
>         return retval;
> 
>     lldb::SBThread thread_sb(thread);
> -    
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> -        
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(thread_sb, session_dict = FindSessionDictionary(session_dictionary_name));
> +    PyObject *ThreadObj_PyObj = SBTypeToSWIGWrapper(thread_sb);
> +
> +    if (ThreadObj_PyObj == NULL)
> +        return retval;
> 
> -        Py_XINCREF (session_dict);
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> 
> -        if (PyObjectToString(pvalue,output))
> -            retval = true;
> +    if (session_dict != NULL)
> +    {
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> 
> -        Py_XDECREF(pvalue);
> +        if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
> +        {
> +            PyErr_Clear();
> +            return true;
> +        }
> +
> +        if (pfunc == NULL)
> +            return true;
> +        else
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (2);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return retval;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, ThreadObj_PyObj);  // This "steals" a reference to ThreadObj_PyObj
> +                PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                else
> +                {
> +                    if (PyString_Check(pvalue))
> +                    {
> +                        output.assign(PyString_AsString(pvalue));
> +                        retval = true;
> +                    }
> +                    else
> +                    {
> +                        output.clear();
> +                        retval = false;
> +                    }
> +                    Py_XDECREF (pvalue);
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
>     }
> -    
>     return retval;
> }
> 
> @@ -793,27 +1080,75 @@ std::string& output)
>         return retval;
> 
>     lldb::SBTarget target_sb(target);
> -    
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> -        
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(target_sb, session_dict = FindSessionDictionary(session_dictionary_name));
> +    PyObject *TargetObj_PyObj = SBTypeToSWIGWrapper(target_sb);
> +
> +    if (TargetObj_PyObj == NULL)
> +        return retval;
> 
> -        Py_XINCREF (session_dict);
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> 
> -        if (PyObjectToString(pvalue,output))
> -            retval = true;
> +    if (session_dict != NULL)
> +    {
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> 
> -        Py_XDECREF(pvalue);
> +        if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
> +        {
> +            PyErr_Clear();
> +            return true;
> +        }
> +
> +        if (pfunc == NULL)
> +            return true;
> +        else
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (2);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return retval;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, TargetObj_PyObj);  // This "steals" a reference to TargetObj_PyObj
> +                PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                else
> +                {
> +                    if (PyString_Check(pvalue))
> +                    {
> +                        output.assign(PyString_AsString(pvalue));
> +                        retval = true;
> +                    }
> +                    else
> +                    {
> +                        output.clear();
> +                        retval = false;
> +                    }
> +                    Py_XDECREF (pvalue);
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
>     }
> -    
>     return retval;
> }
> 
> @@ -831,27 +1166,75 @@ std::string& output)
>         return retval;
> 
>     lldb::SBFrame frame_sb(frame);
> -    
> -    {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> -        
> -        if (!pfunc)
> -            return retval;
> -        
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(frame_sb, session_dict = FindSessionDictionary(session_dictionary_name));
> +    PyObject *FrameObj_PyObj = SBTypeToSWIGWrapper(frame_sb);
> +
> +    if (FrameObj_PyObj == NULL)
> +        return retval;
> 
> -        Py_XINCREF (session_dict);
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> 
> -        if (PyObjectToString(pvalue,output))
> -            retval = true;
> +    if (session_dict != NULL)
> +    {
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> 
> -        Py_XDECREF(pvalue);
> +        if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
> +        {
> +            PyErr_Clear();
> +            return true;
> +        }
> +
> +        if (pfunc == NULL)
> +            return true;
> +        else
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (2);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return retval;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, FrameObj_PyObj);  // This "steals" a reference to FrameObj_PyObj
> +                PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                else
> +                {
> +                    if (PyString_Check(pvalue))
> +                    {
> +                        output.assign(PyString_AsString(pvalue));
> +                        retval = true;
> +                    }
> +                    else
> +                    {
> +                        output.clear();
> +                        retval = false;
> +                    }
> +                    Py_XDECREF (pvalue);
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
>     }
> -    
>     return retval;
> }
> 
> @@ -863,33 +1246,78 @@ LLDBSwigPythonCallModuleInit
>     lldb::DebuggerSP& debugger
> )
> {
> -    bool retval = false;
> 
>     lldb::SBDebugger debugger_sb(debugger);
> 
> +    bool retval = false;
> +
> +    PyObject *DebuggerObj_PyObj = SBTypeToSWIGWrapper(debugger_sb);
> +
> +    if (DebuggerObj_PyObj == NULL)
> +        return retval;
> +        
> +    if (python_module_name == NULL || python_module_name[0] == '\0' || !session_dictionary_name)
> +        return retval;
> +
> +    PyObject *session_dict, *pfunc;
> +    PyObject *pargs, *pvalue;
> +    
> +    session_dict = FindSessionDictionary (session_dictionary_name);
> +    
>     std::string python_function_name_string = python_module_name;
>     python_function_name_string += ".__lldb_init_module";
>     const char* python_function_name = python_function_name_string.c_str();
> 
> +    if (session_dict != NULL)
>     {
> -        PyErr_Cleaner py_err_cleaner(true);
> -        
> -        PyCallable pfunc = PyCallable::FindWithFunctionName(python_function_name,session_dictionary_name);
> +        pfunc = ResolvePythonName (python_function_name, session_dict);
> 
> -        if (!pfunc)
> +        if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
> +        {
> +            PyErr_Clear();
>             return true;
> -        
> -        PyObject* session_dict = NULL;
> -        PyObject* pvalue = NULL;
> -        pvalue = pfunc(debugger_sb, session_dict = FindSessionDictionary(session_dictionary_name));
> -        
> -        Py_XINCREF (session_dict);
> -        
> -        retval = true;
> -        
> -        Py_XDECREF(pvalue);
> +        }
> +
> +        if (pfunc == NULL)
> +            return true;
> +        else
> +        {
> +            // Set up the arguments and call the function.
> +                
> +            if (PyCallable_Check (pfunc))
> +            {
> +                pargs = PyTuple_New (2);
> +                if (pargs == NULL)
> +                {
> +                    if (PyErr_Occurred())
> +                        PyErr_Clear();
> +                    return retval;
> +                }
> +                
> +                PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj);  // This "steals" a reference to DebuggerObj_PyObj
> +                PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
> +                pvalue = PyObject_CallObject (pfunc, pargs);
> +                Py_XDECREF (pargs);
> +                
> +                if (PyErr_Occurred ())
> +                {
> +                    PyErr_Print();
> +                    PyErr_Clear();
> +                }
> +                else
> +                {
> +                    retval = true;
> +                    Py_XDECREF (pvalue);
> +                }
> +                Py_INCREF (session_dict);
> +            }
> +            else if (PyErr_Occurred())
> +            {
> +                PyErr_Print();
> +                PyErr_Clear();
> +            }
> +        }
>     }
> -    
>     return retval;
> }
> %}
> 
> Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original)
> +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Wed Jul  3 12:58:31 2013
> @@ -8,10 +8,8 @@
> //===----------------------------------------------------------------------===//
> 
> #include "lldb/API/SBCommandReturnObject.h"
> -#include "lldb/API/SBError.h"
> #include "lldb/API/SBStream.h"
> 
> -#include "lldb/Core/Error.h"
> #include "lldb/Core/Log.h"
> #include "lldb/Interpreter/CommandReturnObject.h"
> 
> @@ -331,21 +329,3 @@ SBCommandReturnObject::Printf(const char
>     return 0;
> }
> 
> -void
> -SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_error_cstr)
> -{
> -    if (m_opaque_ap.get())
> -    {
> -        if (error.IsValid())
> -            m_opaque_ap->SetError(error.ref(), fallback_error_cstr);
> -        else if (fallback_error_cstr)
> -            m_opaque_ap->SetError(Error(), fallback_error_cstr);
> -    }
> -}
> -
> -void
> -SBCommandReturnObject::SetError (const char *error_cstr)
> -{
> -    if (m_opaque_ap.get() && error_cstr)
> -        m_opaque_ap->SetError(error_cstr);
> -}
> 
> Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Jul  3 12:58:31 2013
> @@ -1328,9 +1328,7 @@ protected:
>             // Don't change the status if the command already set it...
>             if (result.GetStatus() == eReturnStatusInvalid)
>             {
> -                if (result.GetErrorData() && result.GetErrorData()[0])
> -                    result.SetStatus(eReturnStatusFailed);
> -                else if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
> +                if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
>                     result.SetStatus(eReturnStatusSuccessFinishNoResult);
>                 else
>                     result.SetStatus(eReturnStatusSuccessFinishResult);
> 
> Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original)
> +++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Wed Jul  3 12:58:31 2013
> @@ -143,19 +143,9 @@ CommandReturnObject::SetError (const Err
>     const char *error_cstr = error.AsCString();
>     if (error_cstr == NULL)
>         error_cstr = fallback_error_cstr;
> -    SetError(error_cstr);
> +    AppendError (error_cstr);
> +    SetStatus (eReturnStatusFailed);
> }
> -
> -void
> -CommandReturnObject::SetError (const char *error_cstr)
> -{
> -    if (error_cstr)
> -    {
> -        AppendError (error_cstr);
> -        SetStatus (eReturnStatusFailed);
> -    }
> -}
> -
> // Similar to AppendError, but do not prepend 'Error: ' to message, and
> // don't append "\n" to the end of it.
> 
> 
> Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
> +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Jul  3 12:58:31 2013
> @@ -115,6 +115,7 @@ LLDBSwigPythonCallCommand (const char *p
>                            const char *session_dictionary_name,
>                            lldb::DebuggerSP& debugger,
>                            const char* args,
> +                           std::string& err_msg,
>                            lldb_private::CommandReturnObject& cmd_retobj);
> 
> extern "C" bool
> @@ -2969,7 +2970,7 @@ ScriptInterpreterPython::RunScriptBasedC
>         return false;
>     }
> 
> -    bool ret_val = false;
> +    bool ret_val;
> 
>     std::string err_msg;
> 
> @@ -2994,11 +2995,12 @@ ScriptInterpreterPython::RunScriptBasedC
>                                              m_dictionary_name.c_str(),
>                                              debugger_sp,
>                                              args,
> +                                             err_msg,
>                                              cmd_retobj);
>     }
> 
>     if (!ret_val)
> -        error.SetErrorString("unable to execute script function");
> +        error.SetErrorString(err_msg.c_str());
>     else
>         error.Clear();
> 
> 
> Modified: lldb/trunk/test/functionalities/command_script/welcome.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/welcome.py?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/test/functionalities/command_script/welcome.py (original)
> +++ lldb/trunk/test/functionalities/command_script/welcome.py Wed Jul  3 12:58:31 2013
> @@ -13,7 +13,9 @@ def target_name_impl(debugger, args, res
>     file = target.GetExecutable()
>     print >>result,  ('Current target ' + file.GetFilename())
>     if args == 'fail':
> -        result.SetError('a test for error in command')
> +        return 'a test for error in command'
> +    else:
> +        return None
> 
> def print_wait_impl(debugger, args, result, dict):
>     result.SetImmediateOutputFile(sys.stdout)
> @@ -23,10 +25,11 @@ def print_wait_impl(debugger, args, resu
>     print >>result,  ('Still doing long task..')
>     time.sleep(1)
>     print >>result,  ('Done; if you saw the delays I am doing OK')
> +    return None
> 
> def check_for_synchro(debugger, args, result, dict):
>     if debugger.GetAsync() == True:
>         print >>result,  ('I am running async')
>     if debugger.GetAsync() == False:
>         print >>result,  ('I am running sync')
> -
> +    return None
> 
> Modified: lldb/trunk/test/help/TestHelp.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=185560&r1=185559&r2=185560&view=diff
> ==============================================================================
> --- lldb/trunk/test/help/TestHelp.py (original)
> +++ lldb/trunk/test/help/TestHelp.py Wed Jul  3 12:58:31 2013
> @@ -124,7 +124,7 @@ class HelpCommandTestCase(TestBase):
>         """Command 'help image du line' is not ambiguous and should work."""
>         # 'image' is an alias for 'target modules'.
>         self.expect("help image du line",
> -            substrs = ['Dump the line table for one or more compilation units'])
> +            substrs = ['Dump the debug symbol file for one or more target modules'])
> 
>     def test_help_target_variable_syntax(self):
>         """Command 'help target variable' should display <variable-name> ..."""
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130708/5e443de3/attachment.html>


More information about the lldb-commits mailing list