summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 4db56d4ac23..e84cd699549 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -763,13 +763,13 @@ ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string,
case eCharPtr: // "char *"
{
const char format[3] = "s#";
- success = PyArg_Parse (py_return, format, (char **) &ret_value);
+ success = PyArg_Parse (py_return, format, (char **) ret_value);
break;
}
case eCharStrOrNone: // char* or NULL if py_return == Py_None
{
const char format[3] = "z";
- success = PyArg_Parse (py_return, format, (char **) &ret_value);
+ success = PyArg_Parse (py_return, format, (char **) ret_value);
break;
}
case eBool:
@@ -1972,6 +1972,26 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function,
}
+// in Python, a special attribute __doc__ contains the docstring
+// for an object (function, method, class, ...) if any is defined
+// Otherwise, the attribute's value is None
+std::string
+ScriptInterpreterPython::GetDocumentationForItem(const char* item)
+{
+ std::string command(item);
+ command += ".__doc__";
+
+ char* result_ptr = NULL; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully
+
+ if (ExecuteOneLineWithReturn (command.c_str(),
+ ScriptInterpreter::eCharStrOrNone,
+ &result_ptr) && result_ptr)
+ {
+ return std::string(result_ptr);
+ }
+ else
+ return std::string("");
+}
void
ScriptInterpreterPython::InitializeInterpreter (SWIGInitCallback python_swig_init_callback,
OpenPOWER on IntegriCloud