When defining a scripted command, it is possible to provide a docstring and that will be used as the help text for the command
If no docstring is provided, a default help text is created LLDB will refuse to create scripted commands if the scripting language is anything but Python Some additional comments in AppleObjCRuntimeV2.cpp to describe the memory layout expected by the dynamic type lookup code llvm-svn: 137801
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user