<rdar://problem/14266411>

The semi-unofficial way of returning a status from a Python command was to return a string (e.g. return "no such variable was found") that LLDB would pick as a clue of an error having happened

This checkin changes that:
- SBCommandReturnObject now exports a SetError() call, which can take an SBError or a plain C-string
- script commands now drop any return value and expect the SBCommandReturnObject ("return object") to be filled in appropriately - if you do nothing, a success will be assumed

If your commands were relying on returning a value and having LLDB pick that up as an error, please change your commands to SetError() through the return object or expect changes in behavior

llvm-svn: 184893
This commit is contained in:
Enrico Granata committed 2013-06-25 23:43:28 +00:00
1 parent cc077ad634
commit b4675a4e12
12 files changed
+62 -37

No files matched your search

+3 -22
View File
@@ -318,7 +318,7 @@ LLDBSwigPythonCallTypeScript
if (!python_function_name || !session_dictionary)
return false;
PyObject *session_dict = (PyObject*)session_dictionary, *pfunc_impl = NULL, *pargs = NULL, *pvalue = NULL;
PyObject *session_dict = (PyObject*)session_dictionary, *pfunc_impl = NULL, *pvalue = NULL;
if (pyfunct_wrapper && *pyfunct_wrapper && PyFunction_Check (*pyfunct_wrapper))
{
@@ -475,10 +475,6 @@ LLDBSwigPython_GetChildAtIndex
uint32_t idx
)
{
static char callee_name[] = "get_child_at_index";
static char param_format[] = "i";
PyErr_Cleaner py_err_cleaner(true);
PyCallable pfunc = PyCallable::FindWithMemberFunction(implementor,"get_child_at_index");
@@ -628,7 +624,6 @@ LLDBSwigPythonCallCommand
const char *session_dictionary_name,
lldb::DebuggerSP& debugger,
const char* args,
std::string& err_msg,
lldb_private::CommandReturnObject& cmd_retobj
)
{
@@ -653,23 +648,9 @@ LLDBSwigPythonCallCommand
pvalue = pfunc(debugger_sb, args, &cmd_retobj_sb, session_dict = FindSessionDictionary(session_dictionary_name));
Py_XINCREF (session_dict);
if (pvalue != NULL)
{
if (pvalue == Py_None) // no error
{
err_msg.clear();
retval = true;
}
else
{
// return value is an error string
PyObjectToString(pvalue,err_msg);
retval = false;
}
}
Py_XDECREF (pvalue);
retval = true;
}
return retval;