summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-09-18 21:53:02 +0000
committerEnrico Granata <egranata@apple.com>2012-09-18 21:53:02 +0000
commitfac939e918558d88b80561e764989e95a5576b1c (patch)
tree60b9f7cb6d7b5a626d1717f6d6c7c37be6bd36ce
parent14f082b69d7309ddc2abb5bc6a6207ce9b1c2c11 (diff)
downloadbcm5719-llvm-fac939e918558d88b80561e764989e95a5576b1c.tar.gz
bcm5719-llvm-fac939e918558d88b80561e764989e95a5576b1c.zip
<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
llvm-svn: 164172
-rw-r--r--lldb/include/lldb/Interpreter/CommandObject.h2
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreter.h7
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreterPython.h4
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp28
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp17
5 files changed, 40 insertions, 18 deletions
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index 76936c4c26b..54eaa8f9aa9 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -99,7 +99,7 @@ public:
const char *
GetHelp ();
- const char *
+ virtual const char *
GetHelpLong ();
const char *
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 1c0dcf7ec82..1ccab0d21af 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -298,10 +298,11 @@ public:
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
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
index 7bc49a7a7d9..c2105c76c04 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h
@@ -149,8 +149,8 @@ public:
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,
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index a1a65ae4c91..64f80a0f51d 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1162,6 +1162,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw
private:
std::string m_function_name;
ScriptedCommandSynchronicity m_synchro;
+ bool m_fetched_help_long;
public:
@@ -1174,15 +1175,9 @@ public:
(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 @@ public:
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)
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index fec70e301cc..d0858739b12 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -2542,9 +2542,12 @@ 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)
+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 @@ ScriptInterpreterPython::GetDocumentationForItem(const char* item)
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
OpenPOWER on IntegriCloud