]> git.saurik.com Git - apple/xnu.git/blame_incremental - tools/lldbmacros/kauth.py
xnu-3248.20.55.tar.gz
[apple/xnu.git] / tools / lldbmacros / kauth.py
... / ...
CommitLineData
1""" Please make sure you read the README file COMPLETELY BEFORE reading anything below.
2 It is very critical that you read coding guidelines in Section E in README file.
3"""
4
5from xnu import *
6from utils import *
7
8# Macro: walkkauthcache
9@lldb_command('walkkauthcache')
10def WalkKauthCache(cmd_args=None):
11 """ Walks the bins of the kauth credential hash cache and prints out the
12 number of bins and bin usage information.
13 """
14 PrintKauthCache()
15# EndMacro: walkkauthcache
16
17def PrintKauthCache(cmd_args=None):
18 """ Routine to determine the size of the kauth cache, walk the bins
19 and print out usage information.
20 """
21 anchor = unsigned(kern.globals.kauth_cred_table_anchor)
22 alloc_info_struct = anchor - sizeof('struct _mhead')
23 alloc_info = kern.GetValueFromAddress(alloc_info_struct, 'struct _mhead*')
24 alloc_size = unsigned(alloc_info.mlen) - (sizeof('struct _mhead'))
25 table_entries = alloc_size / sizeof('struct kauth_cred_entry_head')
26 anchor = kern.globals.kauth_cred_table_anchor
27 print "Cred cache has: " + str(table_entries) + " buckets\n"
28 print "Number of items in each bucket ... \n"
29 for i in range(0, table_entries):
30 numinbucket = 0
31 for kauth_cred in IterateTAILQ_HEAD(anchor[i], "cr_link"):
32 numinbucket += 1
33 #print str(kauth_cred.cr_posix)
34 #print str(kauth_cred.cr_ref)
35 print str(numinbucket) + "\n"