2020-07-29 15:13:58 +00:00
|
|
|
# Copyright (c) 2020 Google LLC. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
# The following Skia types can be natively visualized in LLDB:
|
2020-07-30 20:11:41 +00:00
|
|
|
# - SkAutoTArray, SkAutoSTArray
|
2020-07-29 15:13:58 +00:00
|
|
|
# - SkString
|
2020-07-30 20:11:41 +00:00
|
|
|
# - SkTArray, SkSTArray
|
|
|
|
# - sk_sp
|
2020-07-29 15:13:58 +00:00
|
|
|
#
|
|
|
|
# To enable LLDB debugging support, run the following command at the (lldb) prompt:
|
|
|
|
#
|
|
|
|
# command script import (your-skia-local-path)/platform_tools/debugging/lldb/skia.py
|
|
|
|
#
|
|
|
|
# This can be automatically enabled at the start of every debugging session by creating a
|
|
|
|
# ~/.lldbinit file which contains this command.
|
|
|
|
|
|
|
|
import lldb
|
|
|
|
|
|
|
|
def SkString_SummaryProvider(valobj, dict):
|
|
|
|
fRec = valobj.GetChildMemberWithName('fRec')
|
2020-08-04 19:26:04 +00:00
|
|
|
# The fPtr inside fRec is automatically consumed by sk_sp_SynthProvider.
|
|
|
|
fLength = fRec.GetChildMemberWithName('fLength')
|
2020-07-29 15:13:58 +00:00
|
|
|
if fLength.GetValueAsUnsigned(0) <= 0:
|
|
|
|
return '""'
|
2020-08-04 19:26:04 +00:00
|
|
|
fBeginningOfData = fRec.GetChildMemberWithName('fBeginningOfData')
|
2020-07-29 15:13:58 +00:00
|
|
|
|
|
|
|
# Fetch string contents into an SBData.
|
|
|
|
string = fBeginningOfData.AddressOf().GetPointeeData(0, fLength.GetValueAsUnsigned(0))
|
|
|
|
# Zero terminate the SBData. (This actually adds four zero bytes, but that's harmless.)
|
|
|
|
string.Append(lldb.SBData.CreateDataFromInt(0))
|
|
|
|
# Convert our SBData into a string.
|
|
|
|
error = lldb.SBError()
|
|
|
|
string = string.GetString(error, 0)
|
|
|
|
if error.Fail():
|
|
|
|
return '<error: ' + error.GetCString() + '>'
|
|
|
|
else:
|
|
|
|
return '"' + string + '"'
|
|
|
|
|
2020-07-29 16:05:12 +00:00
|
|
|
|
2020-07-29 15:13:58 +00:00
|
|
|
class SkTArray_SynthProvider:
|
|
|
|
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
self.valobj = valobj
|
|
|
|
|
|
|
|
def num_children(self):
|
|
|
|
try:
|
|
|
|
count = self.fCount.GetValueAsSigned(0)
|
|
|
|
return count if count >= 0 else 0
|
|
|
|
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.fItemArray.CreateChildAtOffset('[' + str(index) + ']',
|
|
|
|
offset, self.dataType)
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
try:
|
|
|
|
self.fItemArray = self.valobj.GetChildMemberWithName('fItemArray')
|
|
|
|
self.fCount = self.valobj.GetChildMemberWithName('fCount')
|
|
|
|
self.dataType = self.fItemArray.GetType().GetPointeeType()
|
|
|
|
self.dataSize = self.dataType.GetByteSize()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def has_children(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2020-07-29 16:05:12 +00:00
|
|
|
class SkAutoTArray_SynthProvider:
|
|
|
|
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
self.valobj = valobj
|
|
|
|
|
|
|
|
def num_children(self):
|
|
|
|
try:
|
|
|
|
count = self.fCount.GetValueAsSigned(0)
|
|
|
|
return count if count >= 0 else 0
|
|
|
|
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.fValue.CreateChildAtOffset('[' + str(index) + ']',
|
|
|
|
offset, self.dataType)
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
try:
|
|
|
|
self.fCount = self.valobj.GetChildMemberWithName('fCount')
|
|
|
|
fArray = self.valobj.GetChildMemberWithName('fArray')
|
|
|
|
# These lookups rely on implementation details of unique_ptr and __compressed_pair.
|
|
|
|
ptr = fArray.GetChildMemberWithName('__ptr_')
|
|
|
|
self.fValue = ptr.GetChildMemberWithName('__value_')
|
|
|
|
self.dataType = self.fValue.GetType().GetPointeeType()
|
|
|
|
self.dataSize = self.dataType.GetByteSize()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def has_children(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2020-07-30 19:59:58 +00:00
|
|
|
class sk_sp_SynthProvider:
|
|
|
|
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
self.valobj = valobj
|
|
|
|
|
|
|
|
def num_children(self):
|
|
|
|
return self.fPtr.GetNumChildren()
|
|
|
|
|
|
|
|
def get_child_at_index(self, index):
|
|
|
|
try:
|
|
|
|
return self.fPtr.GetChildAtIndex(index)
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def get_child_index(self, name):
|
|
|
|
return self.fPtr.GetIndexOfChildWithName(name)
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
try:
|
|
|
|
self.fPtr = self.valobj.GetChildMemberWithName('fPtr')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-07-29 15:13:58 +00:00
|
|
|
def __lldb_init_module(debugger, dict):
|
|
|
|
debugger.HandleCommand(
|
|
|
|
'type summary add -F skia.SkString_SummaryProvider "SkString" -w skia')
|
2020-07-30 19:59:58 +00:00
|
|
|
debugger.HandleCommand(
|
|
|
|
'type synthetic add -l skia.sk_sp_SynthProvider -x "^sk_sp<.+>$" -w skia')
|
|
|
|
debugger.HandleCommand(
|
|
|
|
'type summary add --summary-string "fPtr = ${var.fPtr}" -x "^sk_sp<.+>$" -w skia')
|
2020-07-29 15:13:58 +00:00
|
|
|
debugger.HandleCommand(
|
|
|
|
'type synthetic add -l skia.SkTArray_SynthProvider -x "^SkS?TArray<.+>$" -w skia')
|
|
|
|
debugger.HandleCommand(
|
|
|
|
'type summary add --summary-string "size=${svar%#}" -e -x "^SkS?TArray<.+>$" -w skia')
|
2020-07-29 16:05:12 +00:00
|
|
|
debugger.HandleCommand(
|
|
|
|
'type synthetic add -l skia.SkAutoTArray_SynthProvider -x "^SkAutoS?TArray<.+>$" -w skia')
|
|
|
|
debugger.HandleCommand(
|
|
|
|
'type summary add --summary-string "size=${svar%#}" -e -x "^SkAutoS?TArray<.+>$" -w skia')
|
2020-07-29 15:13:58 +00:00
|
|
|
debugger.HandleCommand("type category enable skia")
|