]>
Commit | Line | Data |
---|---|---|
fe8ab488 A |
1 | from xnu import * |
2 | from utils import * | |
3 | ||
4 | ||
5 | @lldb_type_summary(['bank_element', 'bank_element_t']) | |
490019cf | 6 | @header("{0: <20s} {1: <16s} {2: <16s} {3: <16s} {4: <20s} {5: <20s}".format("bank_element", "type", "ref_count", "sync", "task", "process_name")) |
fe8ab488 A |
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. | |
11 | """ | |
490019cf | 12 | format_str = "{0: <#020x} {1: <16s} {2: <16d} {3: <16d}" |
fe8ab488 A |
13 | |
14 | if bank_element.be_type == 0: | |
490019cf | 15 | out_string = format_str.format(bank_element, "BANK_TASK", unsigned(bank_element.be_refs), unsigned(bank_element.be_made)) |
fe8ab488 | 16 | else: |
490019cf | 17 | out_string = format_str.format(bank_element, "BANK_ACCOUNT", unsigned(bank_element.be_refs), unsigned(bank_element.be_made)) |
fe8ab488 A |
18 | |
19 | #if DEVELOPMENT | |
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)) | |
23 | #endif | |
24 | ||
25 | return out_string | |
26 | ||
27 | ||
28 | @lldb_type_summary(['bank_task', 'bank_task_t']) | |
490019cf | 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")) |
fe8ab488 A |
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. | |
34 | """ | |
35 | ||
490019cf | 36 | format_str = "{0: <#020x} {1: <16d} {2: <#020x} {3: <16d} {4: <16d} {5: <16d} {6: <16d} {7: <16d}" |
cb323159 | 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) |
fe8ab488 A |
38 | |
39 | #if DEVELOPMENT | |
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)) | |
43 | #endif | |
44 | return out_string | |
45 | ||
46 | ||
47 | @lldb_type_summary(['bank_account', 'bank_account_t']) | |
490019cf | 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")) |
fe8ab488 A |
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. | |
53 | """ | |
54 | ||
490019cf A |
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)) | |
fe8ab488 A |
57 | |
58 | #if DEVELOPMENT | |
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)) | |
64 | #endif | |
65 | return out_string | |
66 | ||
67 | ||
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> | |
73 | """ | |
74 | if not cmd_args: | |
75 | raise ArgumentError("Please provide arguments") | |
76 | ||
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 | |
82 | print header_str | |
83 | ||
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) | |
86 | return | |
87 | # EndMacro: showbankaccountstopay | |
88 | ||
89 | ||
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> | |
95 | """ | |
96 | if not cmd_args: | |
97 | raise ArgumentError("Please provide arguments") | |
98 | ||
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 | |
104 | print header_str | |
105 | ||
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) | |
108 | return | |
109 | # EndMacro: showbankaccountstocharge | |
110 | ||
111 | ||
112 | #if DEVELOPMENT | |
113 | ||
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 | |
118 | and prints them. | |
119 | usage: (lldb) showallbanktasklist | |
120 | """ | |
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." | |
123 | return False | |
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) | |
127 | return True | |
128 | # EndMacro showallbanktasklist | |
129 | ||
130 | ||
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 | |
135 | and prints them. | |
136 | usage: (lldb) showallbankaccountlist | |
137 | """ | |
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." | |
140 | return False | |
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) | |
144 | return True | |
145 | # EndMacro showallbankaccountlist | |
146 | #endif |