Bug 188936 - lldb-webkit: Pretty-print OptionSet
Summary: lldb-webkit: Pretty-print OptionSet
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on: 189008
Blocks: 189011
  Show dependency treegraph
 
Reported: 2018-08-24 15:46 PDT by Daniel Bates
Modified: 2018-08-30 09:33 PDT (History)
5 users (show)

See Also:


Attachments
Patch and unit tests (8.65 KB, patch)
2018-08-24 15:51 PDT, Daniel Bates
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2018-08-24 15:46:21 PDT
We should add support for pretty-printing OptionSet.
Comment 1 Daniel Bates 2018-08-24 15:51:20 PDT
Created attachment 348050 [details]
Patch and unit tests
Comment 2 Daniel Bates 2018-08-24 15:51:47 PDT
With the proposed patch, here is how it looks to print a variable that is an OptionSet:

(lldb) p checkingTypes
(WTF::OptionSet<WebCore::TextCheckingType>) $3 = { size = 3 } {
  (Spelling) [0] = 0
  (Grammar) [1] = 1
  (Replacement) [2] = 4
}
Comment 3 Simon Fraser (smfr) 2018-08-24 15:55:03 PDT
Comment on attachment 348050 [details]
Patch and unit tests

Very nice.
Comment 4 Daniel Bates 2018-08-24 18:57:03 PDT
Comment on attachment 348050 [details]
Patch and unit tests

View in context: https://bugs.webkit.org/attachment.cgi?id=348050&action=review

> Tools/lldb/lldb_webkit.py:33
> +import operator

Will remoce this before landing.

> Tools/lldb/lldb_webkit.py:613
> +            return self.valobj.CreateValueFromExpression('(%s) [%s]' % (self._elements[index], str(index)), str(index ** 2))

index ** 2  => 2 ** index
Comment 5 Daniel Bates 2018-08-27 09:29:51 PDT
(In reply to Daniel Bates from comment #4)
> Comment on attachment 348050 [details]
> Patch and unit tests
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=348050&action=review
> 
> > Tools/lldb/lldb_webkit.py:33
> > +import operator
> 
> Will remoce this before landing.
> 
> > Tools/lldb/lldb_webkit.py:613
> > +            return self.valobj.CreateValueFromExpression('(%s) [%s]' % (self._elements[index], str(index)), str(index ** 2))
> 
> index ** 2  => 2 ** index

This is not correct because index represents the position in the array of collected enumerators != the enumerator's value. We need to explicitly keep track of the value of each seen enumerator.
Comment 6 Daniel Bates 2018-08-27 09:33:32 PDT
(In reply to Daniel Bates from comment #2)
> With the proposed patch, here is how it looks to print a variable that is an
> OptionSet:
> 
> (lldb) p checkingTypes
> (WTF::OptionSet<WebCore::TextCheckingType>) $3 = { size = 3 } {
>   (Spelling) [0] = 0
>   (Grammar) [1] = 1
>   (Replacement) [2] = 4
> }

Displaying the position in the set (e.g. [1]) does not seem very useful since you cannot index into the set. I am going to simplify this output to only show the name of the enumerator and its value before landing (due to :

(lldb) p checkingTypes
(WTF::OptionSet<WebCore::TextCheckingType>) $3 = { size = 3 } {
  Spelling = 1
  Grammar = 2
  Replacement = 32
}
Comment 7 Daniel Bates 2018-08-27 09:59:48 PDT
Committed r235376: <https://trac.webkit.org/changeset/235376>
Comment 8 Radar WebKit Bug Importer 2018-08-27 10:00:27 PDT
<rdar://problem/43757743>
Comment 9 Daniel Bates 2018-08-27 14:45:15 PDT
(In reply to Daniel Bates from comment #7)
> Committed r235376: <https://trac.webkit.org/changeset/235376>

For some reason the tests lldb_webkit_unittest.TestSummaryProviders.serial_test_WTFOptionSetProvider_simple and lldb_webkit_unittest.TestSummaryProviders.serial_test_WTFOptionSet_SummaryProvider_simple, included in this change, are failing on the Apple High Sierra Debug and Apple Sierra Debug bots. These tests do not fail on the Release variants of these bots (why?). The following is the failure output:

[[
[1772/1787] lldb_webkit_unittest.TestSummaryProviders.serial_test_WTFOptionSetProvider_simple
[1773/1787] lldb_webkit_unittest.TestSummaryProviders.serial_test_WTFOptionSetProvider_simple erred:
  Traceback (most recent call last):
    File "/Volumes/Data/slave/highsierra-debug-tests-wk2/build/Tools/lldb/lldb_webkit_unittest.py", line 193, in serial_test_WTFOptionSetProvider_simple
      self.assertEqual(provider.get_child_at_index(0).GetName(), 'A')
  AttributeError: 'NoneType' object has no attribute 'GetName'
...
[1779/1787] lldb_webkit_unittest.TestSummaryProviders.serial_test_WTFOptionSet_SummaryProvider_simple failed:
  Traceback (most recent call last):
    File "/Volumes/Data/slave/highsierra-debug-tests-wk2/build/Tools/lldb/lldb_webkit_unittest.py", line 181, in serial_test_WTFOptionSet_SummaryProvider_simple
      self.assertEqual(summary, "{ size = 3 }")
  AssertionError: '{ size = 0 }' != '{ size = 3 }'
[1779/1787] dump_class_layout_unittest.TestDumpClassLayout.serial_test_ClassWithTwoVirtualBaseClasses
]]
<https://build.webkit.org/builders/Apple%20High%20Sierra%20Debug%20WK2%20%28Tests%29/builds/4639/steps/webkitpy-test/logs/stdio>

Same error seen on Apple Sierra Debug WK1 (Tests):
<https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK1%20%28Tests%29/builds/9271/steps/webkitpy-test/logs/stdio>

For completeness, the Apple Sierra Release WK2 (Tests) and High Sierra Release WK2 (Tests) output of test-webkitpy is at <https://build.webkit.org/builders/Apple%20Sierra%20Release%20WK2%20%28Tests%29/builds/11327/steps/webkitpy-test/logs/stdio> and <https://build.webkit.org/builders/Apple%20High%20Sierra%20Release%20WK2%20%28Tests%29/builds/6406/steps/webkitpy-test/logs/stdio>, respectively.
Comment 10 WebKit Commit Bot 2018-08-27 14:47:17 PDT
Re-opened since this is blocked by bug 189008
Comment 11 Daniel Bates 2018-08-30 09:33:32 PDT
(In reply to Daniel Bates from comment #9)
> (In reply to Daniel Bates from comment #7)
> > Committed r235376: <https://trac.webkit.org/changeset/235376>
> 
> For some reason the tests
> lldb_webkit_unittest.TestSummaryProviders.
> serial_test_WTFOptionSetProvider_simple and
> lldb_webkit_unittest.TestSummaryProviders.
> serial_test_WTFOptionSet_SummaryProvider_simple, included in this change,
> are failing on the Apple High Sierra Debug and Apple Sierra Debug bots.
> These tests do not fail on the Release variants of these bots (why?). The
> following is the failure output:
> 
> [[
> [1772/1787]
> lldb_webkit_unittest.TestSummaryProviders.
> serial_test_WTFOptionSetProvider_simple
> [1773/1787]
> lldb_webkit_unittest.TestSummaryProviders.
> serial_test_WTFOptionSetProvider_simple erred:
>   Traceback (most recent call last):
>     File
> "/Volumes/Data/slave/highsierra-debug-tests-wk2/build/Tools/lldb/
> lldb_webkit_unittest.py", line 193, in
> serial_test_WTFOptionSetProvider_simple
>       self.assertEqual(provider.get_child_at_index(0).GetName(), 'A')
>   AttributeError: 'NoneType' object has no attribute 'GetName'
> ...
> [1779/1787]
> lldb_webkit_unittest.TestSummaryProviders.
> serial_test_WTFOptionSet_SummaryProvider_simple failed:
>   Traceback (most recent call last):
>     File
> "/Volumes/Data/slave/highsierra-debug-tests-wk2/build/Tools/lldb/
> lldb_webkit_unittest.py", line 181, in
> serial_test_WTFOptionSet_SummaryProvider_simple
>       self.assertEqual(summary, "{ size = 3 }")
>   AssertionError: '{ size = 0 }' != '{ size = 3 }'
> [1779/1787]
> dump_class_layout_unittest.TestDumpClassLayout.
> serial_test_ClassWithTwoVirtualBaseClasses
> ]]
> <https://build.webkit.org/builders/
> Apple%20High%20Sierra%20Debug%20WK2%20%28Tests%29/builds/4639/steps/webkitpy-
> test/logs/stdio>
> 
> Same error seen on Apple Sierra Debug WK1 (Tests):
> <https://build.webkit.org/builders/
> Apple%20Sierra%20Debug%20WK1%20%28Tests%29/builds/9271/steps/webkitpy-test/
> logs/stdio>
> 
> For completeness, the Apple Sierra Release WK2 (Tests) and High Sierra
> Release WK2 (Tests) output of test-webkitpy is at
> <https://build.webkit.org/builders/
> Apple%20Sierra%20Release%20WK2%20%28Tests%29/builds/11327/steps/webkitpy-
> test/logs/stdio> and
> <https://build.webkit.org/builders/
> Apple%20High%20Sierra%20Release%20WK2%20%28Tests%29/builds/6406/steps/
> webkitpy-test/logs/stdio>, respectively.

Filed bug #189011 to fix this.