mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add flake8 to the tidy process for Python files
Fixes #6236 Also included in this commit are the changes need to make flake8 pass for the existing python file
This commit is contained in:
parent
907c051bd1
commit
848c57653c
15 changed files with 113 additions and 68 deletions
|
@ -7,19 +7,22 @@
|
|||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
# A set of simple pretty printers for gdb to make debugging Servo a bit easier.
|
||||
"""
|
||||
A set of simple pretty printers for gdb to make debugging Servo a bit easier.
|
||||
|
||||
# To load these, you need to add something like the following
|
||||
# to your .gdbinit file.
|
||||
#python
|
||||
#import sys
|
||||
#sys.path.insert(0, '/home/<path to git checkout>/servo/src/etc')
|
||||
#import servo_gdb
|
||||
#servo_gdb.register_printers(None)
|
||||
#end
|
||||
To load these, you need to add something like the following to your .gdbinit file:
|
||||
|
||||
python
|
||||
import sys
|
||||
sys.path.insert(0, '/home/<path to git checkout>/servo/src/etc')
|
||||
import servo_gdb
|
||||
servo_gdb.register_printers(None)
|
||||
end
|
||||
"""
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
# Print Au in both raw value and CSS pixels
|
||||
class AuPrinter:
|
||||
def __init__(self, val):
|
||||
|
@ -27,9 +30,10 @@ class AuPrinter:
|
|||
|
||||
def to_string(self):
|
||||
i32_type = gdb.lookup_type("i32")
|
||||
au = self.val.cast(i32_type);
|
||||
au = self.val.cast(i32_type)
|
||||
return "{0}px".format(au / 60.0)
|
||||
|
||||
|
||||
# Print a U8 bitfield as binary
|
||||
class BitFieldU8Printer:
|
||||
def __init__(self, val):
|
||||
|
@ -37,9 +41,10 @@ class BitFieldU8Printer:
|
|||
|
||||
def to_string(self):
|
||||
u8_type = gdb.lookup_type("u8")
|
||||
value = self.val.cast(u8_type);
|
||||
value = self.val.cast(u8_type)
|
||||
return "[{0:#010b}]".format(int(value))
|
||||
|
||||
|
||||
# Print a struct with fields as children
|
||||
class ChildPrinter:
|
||||
def __init__(self, val):
|
||||
|
@ -48,12 +53,13 @@ class ChildPrinter:
|
|||
def children(self):
|
||||
children = []
|
||||
for f in self.val.type.fields():
|
||||
children.append( (f.name, self.val[f.name]) )
|
||||
children.append((f.name, self.val[f.name]))
|
||||
return children
|
||||
|
||||
def to_string(self):
|
||||
return None
|
||||
|
||||
|
||||
# Allow a trusted node to be dereferenced in the debugger
|
||||
class TrustedNodeAddressPrinter:
|
||||
def __init__(self, val):
|
||||
|
@ -67,6 +73,7 @@ class TrustedNodeAddressPrinter:
|
|||
def to_string(self):
|
||||
return self.val.address
|
||||
|
||||
|
||||
# Extract a node type ID from enum
|
||||
class NodeTypeIdPrinter:
|
||||
def __init__(self, val):
|
||||
|
@ -75,9 +82,10 @@ class NodeTypeIdPrinter:
|
|||
def to_string(self):
|
||||
u8_ptr_type = gdb.lookup_type("u8").pointer()
|
||||
enum_0 = self.val.address.cast(u8_ptr_type).dereference()
|
||||
enum_type = self.val.type.fields()[int(enum_0)].type;
|
||||
enum_type = self.val.type.fields()[int(enum_0)].type
|
||||
return str(enum_type).lstrip('struct ')
|
||||
|
||||
|
||||
# Printer for std::Option<>
|
||||
class OptionPrinter:
|
||||
def __init__(self, val):
|
||||
|
@ -111,6 +119,7 @@ class OptionPrinter:
|
|||
def to_string(self):
|
||||
return None
|
||||
|
||||
|
||||
# Useful for debugging when type is unknown
|
||||
class TestPrinter:
|
||||
def __init__(self, val):
|
||||
|
@ -129,13 +138,15 @@ type_map = [
|
|||
('Option', OptionPrinter),
|
||||
]
|
||||
|
||||
def lookup_servo_type (val):
|
||||
|
||||
def lookup_servo_type(val):
|
||||
val_type = str(val.type)
|
||||
for (type_name, printer) in type_map:
|
||||
if val_type == type_name or val_type.endswith("::"+type_name):
|
||||
if val_type == type_name or val_type.endswith("::" + type_name):
|
||||
return printer(val)
|
||||
return None
|
||||
#return TestPrinter(val)
|
||||
# return TestPrinter(val)
|
||||
|
||||
|
||||
def register_printers(obj):
|
||||
gdb.pretty_printers.append(lookup_servo_type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue