[Lldb-commits] [lldb] r149388 - in /lldb/trunk: examples/summaries/objc.py include/lldb/Core/FormatManager.h scripts/Python/finish-swig-Python-LLDB.sh source/Core/FormatManager.cpp source/Interpreter/ScriptInterpreterPython.cpp

Enrico Granata granata.enrico at gmail.com
Tue Jan 31 09:01:52 PST 2012


Author: enrico
Date: Tue Jan 31 11:01:51 2012
New Revision: 149388

URL: http://llvm.org/viewvc/llvm-project?rev=149388&view=rev
Log:
This commit provides a new default summary for Objective-C boolean variables, which shows YES or NO instead of the character value. A new category named objc is added to contain this summary provider. Any future Objective-C related formatters would probably fit here

Added:
    lldb/trunk/examples/summaries/objc.py
Modified:
    lldb/trunk/include/lldb/Core/FormatManager.h
    lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
    lldb/trunk/source/Core/FormatManager.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Added: lldb/trunk/examples/summaries/objc.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/objc.py?rev=149388&view=auto
==============================================================================
--- lldb/trunk/examples/summaries/objc.py (added)
+++ lldb/trunk/examples/summaries/objc.py Tue Jan 31 11:01:51 2012
@@ -0,0 +1,9 @@
+# Summaries for common ObjC types that require Python scripting
+# to be generated fit into this file
+
+def BOOL_SummaryProvider (valobj,dict):
+	if valobj.GetValueAsUnsigned() == 0:
+		return "NO"
+	else:
+		return "YES"
+		

Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=149388&r1=149387&r2=149388&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Tue Jan 31 11:01:51 2012
@@ -508,6 +508,7 @@
     ConstString m_default_category_name;
     ConstString m_system_category_name;
     ConstString m_gnu_cpp_category_name;
+    ConstString m_objc_category_name;
     
     CategoryMap&
     GetCategories ()

Modified: lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh?rev=149388&r1=149387&r2=149388&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh (original)
+++ lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh Tue Jan 31 11:01:51 2012
@@ -184,6 +184,21 @@
     fi
 fi
 
+# Copy the ObjC formatters over to the framework Python directory
+if [ -f "${SRC_ROOT}/examples/synthetic/objc.py" ]
+then
+    if [ $Debug == 1 ]
+    then
+        echo "Copying objc.py to ${framework_python_dir}"
+    fi
+    cp "${SRC_ROOT}/examples/summaries/objc.py" "${framework_python_dir}"
+else
+    if [ $Debug == 1 ]
+    then
+        echo "Unable to find ${SRC_ROOT}/examples/summaries/objc.py"
+    fi
+fi
+
 fi
 
 exit 0

Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=149388&r1=149387&r2=149388&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Tue Jan 31 11:01:51 2012
@@ -560,7 +560,8 @@
     m_categories_map(this),
     m_default_category_name(ConstString("default")),
     m_system_category_name(ConstString("system")), 
-    m_gnu_cpp_category_name(ConstString("gnu-libstdc++"))
+    m_gnu_cpp_category_name(ConstString("gnu-libstdc++")),
+    m_objc_category_name(ConstString("objc"))
 {
     
     // add some default stuff
@@ -584,7 +585,6 @@
     
     lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]"));
     
-    
     FormatCategory::SharedPointer sys_category_sp = GetCategory(m_system_category_name);
     
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
@@ -633,9 +633,23 @@
                                                                                      false,
                                                                                      false,
                                                                                      "gnu_libstdcpp.StdListSynthProvider")));
+
+    lldb::SummaryFormatSP ObjC_BOOL_summary(new ScriptSummaryFormat(false,
+                                                                    false,
+                                                                    false,
+                                                                    true,
+                                                                    true,
+                                                                    false,
+                                                                    "objc.BOOL_SummaryProvider",
+                                                                    ""));
+    FormatCategory::SharedPointer objc_category_sp = GetCategory(m_objc_category_name);
+    objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"),
+                                                 ObjC_BOOL_summary);
 #endif
+    
     // DO NOT change the order of these calls, unless you WANT a change in the priority of these categories
     EnableCategory(m_system_category_name);
+    EnableCategory(m_objc_category_name);
     EnableCategory(m_gnu_cpp_category_name);
     EnableCategory(m_default_category_name);
     

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=149388&r1=149387&r2=149388&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Jan 31 11:01:51 2012
@@ -247,6 +247,10 @@
     run_string.Printf ("run_one_line (%s, 'import gnu_libstdcpp')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
     
+    run_string.Clear();
+    run_string.Printf ("run_one_line (%s, 'import objc')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
+    
     if (m_dbg_stdout != NULL)
     {
         m_new_sysout = PyFile_FromFile (m_dbg_stdout, (char *) "", (char *) "w", _check_and_flush);





More information about the lldb-commits mailing list