Add SkSpan support to the Skia LLDB visualizer.

Change-Id: Ib974e7c1003ca674cbcd67e62b6c2c328c1c2266
Bug: skia:11103
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346639
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
This commit is contained in:
John Stiles 2020-12-22 11:54:15 -05:00 committed by Skia Commit-Bot
parent 977feec5d7
commit 8eccc2938d

View File

@ -46,7 +46,9 @@ class SkTArray_SynthProvider:
def num_children(self):
try:
count = self.fCount.GetValueAsSigned(0)
return count if count >= 0 else 0
count = max(count, 0)
count = min(count, 10000)
return count
except:
return 0
@ -90,7 +92,9 @@ class SkAutoTArray_SynthProvider:
def num_children(self):
try:
count = self.fCount.GetValueAsSigned(0)
return count if count >= 0 else 0
count = max(count, 0)
count = min(count, 10000)
return count
except:
return 0
@ -129,6 +133,53 @@ class SkAutoTArray_SynthProvider:
return True
class SkSpan_SynthProvider:
def __init__(self, valobj, dict):
self.valobj = valobj
def num_children(self):
try:
count = self.fSize.GetValueAsSigned(0)
count = max(count, 0)
count = min(count, 10000)
return count
except:
return 0
def get_child_index(self, name):
try:
return int(name.lstrip('[').rstrip(']'))
except:
return -1
def get_child_at_index(self, index):
if index < 0:
return None
if index >= self.num_children():
return None
try:
offset = index * self.dataSize
return self.fPtr.CreateChildAtOffset('[' + str(index) + ']',
offset, self.dataType)
except:
return None
def update(self):
try:
self.fPtr = self.valobj.GetChildMemberWithName('fPtr')
self.fSize = self.valobj.GetChildMemberWithName('fSize')
self.dataType = self.fPtr.GetType().GetPointeeType()
self.dataSize = self.dataType.GetByteSize()
except:
pass
def has_children(self):
return True
class sk_sp_SynthProvider:
def __init__(self, valobj, dict):
@ -162,6 +213,8 @@ def __lldb_init_module(debugger, dict):
'type summary add --summary-string "fPtr = ${var.fPtr}" -x "^sk_sp<.+>$" -w skia')
debugger.HandleCommand(
'type synthetic add -l skia.SkTArray_SynthProvider -x "^SkS?TArray<.+>$" -w skia')
debugger.HandleCommand(
'type synthetic add -l skia.SkSpan_SynthProvider -x "^SkSpan<.+>$" -w skia')
debugger.HandleCommand(
'type summary add --summary-string "size=${svar%#}" -e -x "^SkS?TArray<.+>$" -w skia')
debugger.HandleCommand(