]>
git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/bank.py
5 @lldb_type_summary(['bank_element', 'bank_element_t'])
6 @header("{0: <20s} {1: <16s} {2: <16s} {3: <16s} {4: <20s} {5: <20s}".format("bank_element", "type", "ref_count", "sync", "task", "process_name"))
7 def GetBankElementSummary(bank_element
):
8 """ Summarizes the bank element
9 params: bank_element = value of the object of type bank_element_t
10 returns: String with summary of the type.
12 format_str
= "{0: <#020x} {1: <16s} {2: <16d} {3: <16d}"
14 if bank_element
.be_type
== 0:
15 out_string
= format_str
.format(bank_element
, "BANK_TASK", unsigned(bank_element
.be_refs
), unsigned(bank_element
.be_made
))
17 out_string
= format_str
.format(bank_element
, "BANK_ACCOUNT", unsigned(bank_element
.be_refs
), unsigned(bank_element
.be_made
))
20 format_str
= "{0: <#020x} {1: <20s}"
21 if hasattr(bank_element
, 'be_task'):
22 out_string
+= " " + format_str
.format(bank_element
.be_task
, GetProcNameForTask(bank_element
.be_task
))
28 @lldb_type_summary(['bank_task', 'bank_task_t'])
29 @header("{0: <20s} {1: <16s} {2: <20s} {3: <16s} {4: <16s} {5: <16s} {6: <16s} {7: <16s} {8: <20s} {9: <20s}".format("bank_task", "pid", "ledger", "ref_count", "sync", "persona id", "uid", "gid", "task", "process_name"))
30 def GetBankTaskSummary(bank_task
):
31 """ Summarizes the bank task
32 params: bank_task = value of the object of type bank_task_t
33 returns: String with summary of the type.
36 format_str
= "{0: <#020x} {1: <16d} {2: <#020x} {3: <16d} {4: <16d} {5: <16d} {6: <16d} {7: <16d}"
37 out_string
= format_str
.format(bank_task
, bank_task
.bt_proc_persona
.pid
, bank_task
.bt_ledger
, unsigned(bank_task
.bt_elem
.be_refs
), unsigned(bank_task
.bt_elem
.be_made
), bank_task
.bt_proc_persona
.persona_id
, bank_task
.bt_proc_persona
.uid
, bank_task
.bt_proc_persona
.gid
)
40 format_str
= "{0: <#020x} {1: <20s}"
41 if hasattr(bank_task
.bt_elem
, 'be_task'):
42 out_string
+= " " + format_str
.format(bank_task
.bt_elem
.be_task
, GetProcNameForTask(bank_task
.bt_elem
.be_task
))
47 @lldb_type_summary(['bank_account', 'bank_account_t'])
48 @header("{0: <20s} {1: <16s} {2: <16s} {3: <16s} {4: <16s} {5: <20s} {6: <16s} {7: <16s} {8: <20s} {9: <20s} {10: <20s} {11: <20s}".format("bank_account", "holder_pid", "merchant_pid", "secure_orig", "proximal_pid", "chit_ledger", "ref_count", "sync", "holder_task", "holder_process", "merchant_task", "merchant_process"))
49 def GetBankAccountSummary(bank_account
):
50 """ Summarizes the bank account
51 params: bank_task = value of the object of type bank_account_t
52 returns: String with summary of the type.
55 format_str
= "{0: <#020x} {1: <16d} {2: <16d} {3: <16d} {4: <16d} {5: <#020x} {6: <16d} {7: <16d}"
56 out_string
= format_str
.format(bank_account
, bank_account
.ba_holder
.bt_proc_persona
.pid
, bank_account
.ba_merchant
.bt_proc_persona
.pid
, bank_account
.ba_secureoriginator
.bt_proc_persona
.pid
, bank_account
.ba_proximateprocess
.bt_proc_persona
.pid
,bank_account
.ba_bill
, unsigned(bank_account
.ba_elem
.be_refs
), unsigned(bank_account
.ba_elem
.be_made
))
59 format_str
= "{0: <#020x} {1: <20s}"
60 if hasattr(bank_account
.ba_holder
.bt_elem
, 'be_task'):
61 out_string
+= " " + format_str
.format(bank_account
.ba_holder
.bt_elem
.be_task
, GetProcNameForTask(bank_account
.ba_holder
.bt_elem
.be_task
))
62 if hasattr(bank_account
.ba_merchant
.bt_elem
, 'be_task'):
63 out_string
+= " " + format_str
.format(bank_account
.ba_merchant
.bt_elem
.be_task
, GetProcNameForTask(bank_account
.ba_merchant
.bt_elem
.be_task
))
68 # Macro: showbankaccountstopay
69 @lldb_command('showbankaccountstopay')
70 def ShowBankAccountsToPay(cmd_args
=None, cmd_options
={}):
71 """ show a list of merchant bank tasks for a bank_task object.
72 Usage: (lldb)showbankaccountstopay <bank_task_t>
75 raise ArgumentError("Please provide arguments")
77 bank_task
= kern
.GetValueFromAddress(cmd_args
[0], 'bank_task_t')
78 print GetBankTaskSummary
.header
79 print GetBankTaskSummary(bank_task
)
80 print "List of Accounts to Pay."
81 header_str
= GetBankAccountSummary
.header
84 for bank_account
in IterateQueue(bank_task
.bt_accounts_to_pay
, 'bank_account_t', 'ba_next_acc_to_pay'):
85 print GetBankAccountSummary(bank_account
)
87 # EndMacro: showbankaccountstopay
90 # Macro: showbankaccountstocharge
91 @lldb_command('showbankaccountstocharge')
92 def ShowBankAccountsToCharge(cmd_args
=None, cmd_options
={}):
93 """ show a list of holder bank tasks for a bank_task object.
94 Usage: (lldb)showbankaccountstocharge <bank_task_t>
97 raise ArgumentError("Please provide arguments")
99 bank_task
= kern
.GetValueFromAddress(cmd_args
[0], 'bank_task_t')
100 print GetBankTaskSummary
.header
101 print GetBankTaskSummary(bank_task
)
102 print "List of Accounts to Charge."
103 header_str
= GetBankAccountSummary
.header
106 for bank_account
in IterateQueue(bank_task
.bt_accounts_to_charge
, 'bank_account_t', 'ba_next_acc_to_charge'):
107 print GetBankAccountSummary(bank_account
)
109 # EndMacro: showbankaccountstocharge
114 # Macro: showallbanktasklist
115 @lldb_command('showallbanktasklist')
116 def ShowAllBankTaskList(cmd_args
=None, cmd_options
={}):
117 """ A DEVELOPMENT macro that walks the list of all allocated bank_task objects
119 usage: (lldb) showallbanktasklist
121 if not hasattr(kern
.globals, 'bank_tasks_list'):
122 print "It seems you are running a build of kernel that does not have the list of all bank_tasks_list."
124 print GetBankTaskSummary
.header
125 for bank_task
in IterateQueue(kern
.globals.bank_tasks_list
, 'bank_task_t', 'bt_global_elt'):
126 print GetBankTaskSummary(bank_task
)
128 # EndMacro showallbanktasklist
131 # Macro: showallbankaccountlist
132 @lldb_command('showallbankaccountlist')
133 def ShowAllBankAccountList(cmd_args
=None, cmd_options
={}):
134 """ A DEVELOPMENT macro that walks the list of all allocated bank_account objects
136 usage: (lldb) showallbankaccountlist
138 if not hasattr(kern
.globals, 'bank_accounts_list'):
139 print "It seems you are running a build of kernel that does not have the list of all bank_accounts_list."
141 print GetBankAccountSummary
.header
142 for bank_account
in IterateQueue(kern
.globals.bank_accounts_list
, 'bank_account_t', 'ba_global_elt'):
143 print GetBankAccountSummary(bank_account
)
145 # EndMacro showallbankaccountlist