]>
git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/ktrace.py
4 # From the defines in bsd/sys/kdebug.h:
44 def GetKdebugClassName(class_num
):
45 return (KdebugClassNames
[class_num
] + ' ({})'.format(class_num) if class_num in KdebugClassNames else 'unknown ({})'.format(class_num
))
47 @lldb_type_summary(['typefilter_t'])
48 @header('{0: <20s}'.format("class") + ' '.join(map('{:02x}'.format
, xrange(0, 255, 8))))
49 def GetKdebugTypefilter(typefilter
):
50 """ Summarizes the provided typefilter.
53 subclasses_per_class
= 256
56 subclasses_per_element
= 64
57 cur_typefilter
= cast(typefilter
, 'uint64_t *')
58 subclasses_fmts
= ' '.join(['{:02x}'] * 8)
60 elements_per_class
= subclasses_per_class
/ subclasses_per_element
63 for i
in xrange(0, classes
):
65 subclasses
= [0] * elements_per_class
67 # check subclass ranges for set bits, remember those subclasses
68 for j
in xrange(0, elements_per_class
):
69 element
= unsigned(cur_typefilter
[i
* elements_per_class
+ j
])
73 subclasses
[j
] = element
75 # if any of the bits were set in a class, print the entire class
77 out_str
+= '{:<20s}'.format(GetKdebugClassName(i
))
78 for element
in subclasses
:
79 # split up the 64-bit values into byte-sized pieces
80 bytes = [unsigned((element
>> i
) & 0xff) for i
in (0, 8, 16, 24, 32, 40, 48, 56)]
81 out_str
+= subclasses_fmts
.format(*bytes)
88 @lldb_command('showkdebugtypefilter')
89 def ShowKdebugTypefilter(cmd_args
=None):
90 """ Show the current kdebug typefilter (or the typefilter at an address)
92 usage: showkdebugtypefilter [<address>]
96 print GetKdebugTypefilter
.header
97 print '-' * len(GetKdebugTypefilter
.header
)
99 typefilter
= kern
.GetValueFromAddress(cmd_args
[0], 'typefilter_t')
100 if unsigned(typefilter
) == 0:
101 raise ArgumentError('argument provided is NULL')
103 print GetKdebugTypefilter()
106 typefilter
= kern
.globals.kdbg_typefilter
107 if unsigned(typefilter
) == 0:
108 raise ArgumentError('no argument provided and active typefilter is not set')
110 print GetKdebugTypefilter
.header
111 print '-' * len(GetKdebugTypefilter
.header
)
112 print GetKdebugTypefilter(typefilter
)