[Lldb-commits] [lldb] r164172 - in /lldb/trunk: include/lldb/Interpreter/CommandObject.h include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Commands/CommandObjectCommands.cpp source/Interpreter/ScriptInterpreterPython.cpp
Enrico Granata
egranata at apple.com
Tue Sep 18 14:53:03 PDT 2012
Author: enrico
Date: Tue Sep 18 16:53:02 2012
New Revision: 164172
URL: http://llvm.org/viewvc/llvm-project?rev=164172&view=rev
Log:
<rdar://problem/12188843> Fixing a problem where a Python command created in the same module where the target function is defined causes the help string not to come out
Modified:
lldb/trunk/include/lldb/Interpreter/CommandObject.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=164172&r1=164171&r2=164172&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Sep 18 16:53:02 2012
@@ -99,7 +99,7 @@
const char *
GetHelp ();
- const char *
+ virtual const char *
GetHelpLong ();
const char *
Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=164172&r1=164171&r2=164172&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Sep 18 16:53:02 2012
@@ -298,10 +298,11 @@
return false;
}
- virtual std::string
- GetDocumentationForItem (const char* item)
+ virtual bool
+ GetDocumentationForItem (const char* item, std::string& dest)
{
- return std::string("");
+ dest.clear();
+ return false;
}
virtual bool
Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=164172&r1=164171&r2=164172&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Sep 18 16:53:02 2012
@@ -149,8 +149,8 @@
lldb::ScriptInterpreterObjectSP& callee_wrapper_sp,
std::string& retval);
- virtual std::string
- GetDocumentationForItem (const char* item);
+ virtual bool
+ GetDocumentationForItem (const char* item, std::string& dest);
virtual bool
LoadScriptingModule (const char* filename,
Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=164172&r1=164171&r2=164172&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Sep 18 16:53:02 2012
@@ -1162,6 +1162,7 @@
private:
std::string m_function_name;
ScriptedCommandSynchronicity m_synchro;
+ bool m_fetched_help_long;
public:
@@ -1174,15 +1175,9 @@
(std::string("Run Python function ") + funct).c_str(),
NULL),
m_function_name(funct),
- m_synchro(synch)
+ m_synchro(synch),
+ m_fetched_help_long(false)
{
- ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
- if (scripter)
- {
- std::string docstring = scripter->GetDocumentationForItem(funct.c_str());
- if (!docstring.empty())
- SetHelpLong(docstring);
- }
}
virtual
@@ -1208,6 +1203,23 @@
return m_synchro;
}
+ virtual const char *
+ GetHelpLong ()
+ {
+ if (!m_fetched_help_long)
+ {
+ ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
+ if (scripter)
+ {
+ std::string docstring;
+ m_fetched_help_long = scripter->GetDocumentationForItem(m_function_name.c_str(),docstring);
+ if (!docstring.empty())
+ SetHelpLong(docstring);
+ }
+ }
+ return CommandObjectRaw::GetHelpLong();
+ }
+
protected:
virtual bool
DoExecute (const char *raw_command_line, CommandReturnObject &result)
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=164172&r1=164171&r2=164172&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 18 16:53:02 2012
@@ -2542,9 +2542,12 @@
// 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)
+bool
+ScriptInterpreterPython::GetDocumentationForItem(const char* item, std::string& dest)
{
+ dest.clear();
+ if (!item || !*item)
+ return false;
std::string command(item);
command += ".__doc__";
@@ -2554,10 +2557,16 @@
ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
&result_ptr, false) && result_ptr)
{
- return std::string(result_ptr);
+ dest.assign(result_ptr);
+ return true;
}
else
- return std::string("");
+ {
+ StreamString str_stream;
+ str_stream.Printf("Function %s was not found. Containing module might be missing.",item);
+ dest.assign(str_stream.GetData());
+ return false;
+ }
}
void
More information about the lldb-commits
mailing list