diff options
| author | Enrico Granata <egranata@apple.com> | 2012-02-29 03:28:49 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2012-02-29 03:28:49 +0000 |
| commit | 7bc0ec3aad663a2c81fddf9da38dba46bba6be19 (patch) | |
| tree | 3c6cb745570d4095b37a18dd0f6cbacf04e79eaf /lldb/source/Core/FormatClasses.cpp | |
| parent | 3203f6b9daa558443f406686522780d0271d7824 (diff) | |
| download | bcm5719-llvm-7bc0ec3aad663a2c81fddf9da38dba46bba6be19.tar.gz bcm5719-llvm-7bc0ec3aad663a2c81fddf9da38dba46bba6be19.zip | |
This commit:
a) adds a Python summary provider for NSDate
b) changes the initialization for ScriptInterpreter so that we are not passing a bulk of Python-specific function pointers around
c) provides a new ScriptInterpreterObject class that allows for ref-count safe wrapping of scripting objects on the C++ side
d) contains much needed performance improvements:
1) the pointer to the Python function generating a scripted summary is now cached instead of looked up every time
2) redundant memory reads in the Python ObjC runtime wrapper are eliminated
3) summaries now use the m_summary_str in ValueObject to store their data instead of passing around ( == copying) an std::string object
e) contains other minor fixes, such as adding descriptive error messages for some cases of summary generation failure
llvm-svn: 151703
Diffstat (limited to 'lldb/source/Core/FormatClasses.cpp')
| -rw-r--r-- | lldb/source/Core/FormatClasses.cpp | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp index d59da37c487..4dd51de8a2c 100644 --- a/lldb/source/Core/FormatClasses.cpp +++ b/lldb/source/Core/FormatClasses.cpp @@ -35,6 +35,7 @@ struct PyObject; #include "lldb/Core/Debugger.h" #include "lldb/Core/FormatClasses.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/ClangASTType.h" @@ -78,11 +79,15 @@ StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags& flags, m_format.assign(format_cstr); } -std::string -StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) +bool +StringSummaryFormat::FormatObject(lldb::ValueObjectSP object, + std::string& retval) { if (!object.get()) - return "NULL"; + { + retval.assign("NULL sp"); + return false; + } StreamString s; ExecutionContext exe_ctx (object->GetExecutionContextRef()); @@ -117,18 +122,28 @@ StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) s.PutChar(')'); - return s.GetString(); + retval.assign(s.GetString()); + return true; } else - return ""; + { + retval.assign("error: oneliner for no children"); + return false; + } } else { if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get())) - return s.GetString(); + { + retval.assign(s.GetString()); + return true; + } else - return ""; + { + retval.assign("error: summary string parsing error"); + return false; + } } } @@ -156,7 +171,8 @@ ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, const char * python_script) : TypeSummaryImpl(flags), m_function_name(), - m_python_script() + m_python_script(), + m_script_function_sp() { if (function_name) m_function_name.assign(function_name); @@ -164,11 +180,26 @@ ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, m_python_script.assign(python_script); } -std::string -ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object) +bool +ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object, + std::string& retval) { - return std::string(ScriptInterpreterPython::CallPythonScriptFunction(m_function_name.c_str(), - object).c_str()); + Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); + + Debugger& dbg = object->GetTargetSP()->GetDebugger(); + ScriptInterpreter *script_interpreter = dbg.GetCommandInterpreter().GetScriptInterpreter(); + + if (!script_interpreter) + { + retval.assign("error: no ScriptInterpreter"); + return false; + } + + return script_interpreter->GetScriptedSummary(m_function_name.c_str(), + object, + m_script_function_sp, + retval); + } std::string |

