[Lldb-commits] [lldb] r259131 - Fix a bug where LLDB would not print the name of the function that a scripted summary is bound to
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 28 16:56:52 PST 2016
Author: enrico
Date: Thu Jan 28 18:56:52 2016
New Revision: 259131
URL: http://llvm.org/viewvc/llvm-project?rev=259131&view=rev
Log:
Fix a bug where LLDB would not print the name of the function that a scripted summary is bound to
rdar://24380076
Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py
lldb/trunk/source/DataFormatters/TypeSummary.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=259131&r1=259130&r2=259131&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Thu Jan 28 18:56:52 2016
@@ -68,6 +68,7 @@ class PythonSynthDataFormatterTestCase(T
# now set up the synth
self.runCmd("script from fooSynthProvider import *")
self.runCmd("type synth add -l fooSynthProvider foo")
+ self.expect("type synthetic list foo", substrs=['fooSynthProvider'])
# check that we get the two real vars and the fake_a variables
self.expect("frame variable f00_1",
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py?rev=259131&r1=259130&r2=259131&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py Thu Jan 28 18:56:52 2016
@@ -52,6 +52,7 @@ class ScriptDataFormatterTestCase(TestBa
script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'Hello from Python, \' + a_val + \' time\'; return str + (\'!\' if a_val == \'1\' else \'s!\');'
self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script)
+ self.expect('type summary list i_am_cool', substrs=[script])
self.expect("frame variable one",
substrs = ['Hello from Python',
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile?rev=259131&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile Thu Jan 28 18:56:52 2016
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py?rev=259131&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py Thu Jan 28 18:56:52 2016
@@ -0,0 +1,60 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class TypeSummaryListScriptTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_typesummarylist_script(self):
+ """Test data formatter commands."""
+ self.build()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', 'Break here')
+
+ def data_formatter_commands(self):
+ """Test printing out Python summary formatters."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type category delete TSLSFormatters', check=False)
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("command script import tslsformatters.py")
+
+ self.expect("frame variable myStruct", substrs=['A data formatter at work'])
+
+ self.expect('type summary list', substrs=['Struct_SummaryFormatter'])
+ self.expect('type summary list Struct', substrs=['Struct_SummaryFormatter'])
+
+
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp?rev=259131&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp Thu Jan 28 18:56:52 2016
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+typedef struct Struct
+{
+ int one;
+ int two;
+} Struct;
+
+int
+main()
+{
+ Struct myStruct = {10, 20};
+ printf ("Break here: %d\n.", myStruct.one);
+ return 0;
+}
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py?rev=259131&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py Thu Jan 28 18:56:52 2016
@@ -0,0 +1,10 @@
+import lldb
+
+def Struct_SummaryFormatter(valobj, internal_dict):
+ return 'A data formatter at work'
+
+category = lldb.debugger.CreateCategory("TSLSFormatters")
+category.SetEnabled(True)
+summary = lldb.SBTypeSummary.CreateWithFunctionName("tslsformatters.Struct_SummaryFormatter", lldb.eTypeOptionCascade)
+spec = lldb.SBTypeNameSpecifier("Struct", False)
+category.AddTypeSummary(spec, summary)
Modified: lldb/trunk/source/DataFormatters/TypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSummary.cpp?rev=259131&r1=259130&r2=259131&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeSummary.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeSummary.cpp Thu Jan 28 18:56:52 2016
@@ -256,14 +256,28 @@ std::string
ScriptSummaryFormat::GetDescription ()
{
StreamString sstr;
- sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)",
+ sstr.Printf ("%s%s%s%s%s%s%s\n ", Cascades() ? "" : " (not cascading)",
!DoesPrintChildren(nullptr) ? "" : " (show children)",
!DoesPrintValue(nullptr) ? " (hide value)" : "",
IsOneLiner() ? " (one-line printout)" : "",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "",
- HideNames(nullptr) ? " (hide member names)" : "",
- m_python_script.c_str());
+ HideNames(nullptr) ? " (hide member names)" : "");
+ if (m_function_name.empty())
+ {
+ if (m_python_script.empty())
+ {
+ sstr.PutCString("no backing script");
+ }
+ else
+ {
+ sstr.PutCString(m_python_script.c_str());
+ }
+ }
+ else
+ {
+ sstr.PutCString(m_function_name.c_str());
+ }
return sstr.GetString();
}
More information about the lldb-commits
mailing list