X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/eb6b6ca394357805f2bdba989abae309f718b4d8..f427ee49d309d8fc33ebf3042c3a775f2f530ded:/tools/lldbmacros/ipc.py?ds=sidebyside diff --git a/tools/lldbmacros/ipc.py b/tools/lldbmacros/ipc.py index a1b02fced..4ae6086e6 100755 --- a/tools/lldbmacros/ipc.py +++ b/tools/lldbmacros/ipc.py @@ -5,13 +5,12 @@ from xnu import * import sys, shlex from utils import * from process import * -from atm import * from bank import * from waitq import * from ioreg import * import xnudefines -@header("{0: <20s} {1: <6s} {2: <6s} {3: <10s} {4: <20s}".format("task", "pid", '#acts', "tablesize", "command")) +@header("{0: <20s} {1: <6s} {2: <6s} {3: <10s} {4: <32s}".format("task", "pid", '#acts', "tablesize", "command")) def GetTaskIPCSummary(task, show_busy = False): """ Display a task's ipc summary. params: @@ -20,7 +19,7 @@ def GetTaskIPCSummary(task, show_busy = False): str - string of ipc info for the task """ out_string = '' - format_string = "{0: <#020x} {1: <6d} {2: <6d} {3: <10d} {4: <20s}" + format_string = "{0: <#020x} {1: <6d} {2: <6d} {3: <10d} {4: <32s}" busy_format = " {0: <10d} {1: <6d}" proc_name = '' if not task.active: @@ -29,7 +28,7 @@ def GetTaskIPCSummary(task, show_busy = False): proc_name += 'halting: ' pval = Cast(task.bsd_info, 'proc *') if int(pval) != 0: - proc_name += str(pval.p_comm) + proc_name += GetProcName(pval) elif int(task.task_imp_base) != 0 and hasattr(task.task_imp_base, 'iit_procname'): proc_name += str(task.task_imp_base.iit_procname) table_size = int(task.itk_space.is_table_size) @@ -40,7 +39,7 @@ def GetTaskIPCSummary(task, show_busy = False): return (out_string, table_size, nbusy, nmsgs) return (out_string, table_size) -@header("{0: <20s} {1: <6s} {2: <6s} {3: <10s} {4: <20s} {5: <10s} {6: <6s}".format("task", "pid", '#acts', "tablesize", "command", "#busyports", "#kmsgs")) +@header("{0: <20s} {1: <6s} {2: <6s} {3: <10s} {4: <32s} {5: <10s} {6: <6s}".format("task", "pid", '#acts', "tablesize", "command", "#busyports", "#kmsgs")) def GetTaskBusyIPCSummary(task): return GetTaskIPCSummary(task, True) @@ -113,7 +112,7 @@ def GetPortDestProc(portp): if tsk.itk_space == spacep: if tsk.bsd_info: destprocp = Cast(tsk.bsd_info, 'struct proc *') - out_str = "{0:s}({1: 0: - func(t, space, ctx, taskports_idx, 0, t.itk_sself, 17) + if unsigned(t.itk_settable_self) > 0: + func(t, space, ctx, taskports_idx, 0, t.itk_settable_self, 17) if unsigned(t.itk_host) > 0: func(t, space, ctx, taskports_idx, 0, t.itk_host, 17) if unsigned(t.itk_bootstrap) > 0: @@ -1216,10 +1242,14 @@ def IterateAllPorts(tasklist, func, ctx, include_psets, follow_busyports, should func(t, space, ctx, taskports_idx, 0, t.itk_debug_control, 17) if unsigned(t.itk_task_access) > 0: func(t, space, ctx, taskports_idx, 0, t.itk_task_access, 17) + if unsigned(t.itk_self[1]) > 0: ## task read port + func(t, space, ctx, taskports_idx, 0, t.itk_self[1], 17) + if unsigned(t.itk_self[2]) > 0: ## task inspect port + func(t, space, ctx, taskports_idx, 0, t.itk_self[2], 17) - ## Task name port (not a send right, just a naked ref) - if unsigned(t.itk_nself) > 0: - func(t, space, ctx, taskports_idx, 0,t.itk_nself, 0) + ## Task name port (not a send right, just a naked ref); TASK_FLAVOR_NAME = 3 + if unsigned(t.itk_self[3]) > 0: + func(t, space, ctx, taskports_idx, 0, t.itk_self[3], 0) ## task resume port is a receive right to resume the task if unsigned(t.itk_resume) > 0: @@ -1257,8 +1287,8 @@ def IterateAllPorts(tasklist, func, ctx, include_psets, follow_busyports, should ## XXX: look at block reason to see if it's in mach_msg_receive - then look at saved state / message ## Thread port (send right) - if unsigned(thval.ith_sself) > 0: - thport = thval.ith_sself + if unsigned(thval.ith_settable_self) > 0: + thport = thval.ith_settable_self func(t, space, ctx, thports_idx, 0, thport, 17) ## see: osfmk/mach/message.h ## Thread special reply port (send-once right) if unsigned(thval.ith_special_reply_port) > 0: @@ -1386,7 +1416,7 @@ def CountPortsCallback(task, space, ctx, entry_idx, ipc_entry, ipc_port, port_di p_intransit.add(unsigned(ipc_port)) if task.active or (task.halting and not task.active): - pname = str(Cast(task.bsd_info, 'proc *').p_name) + pname = GetProcName(Cast(task.bsd_info, 'proc *')) if not pname in p_bytask.keys(): p_bytask[pname] = { 'transit':0, 'table':0, 'other':0 } if entry_idx == intransit_idx: @@ -1610,7 +1640,7 @@ def ShowAllIITs(cmd_args=[], cmd_options={}): print GetIPCImportantTaskSummary(iit) return -@header("{: <18s} {: <3s} {: <18s} {: <20s} {: <18s} {: <8s}".format("ipc_imp_inherit", "don", "to_task", "proc_name", "from_elem", "depth")) +@header("{: <18s} {: <3s} {: <18s} {: <32s} {: <18s} {: <8s}".format("ipc_imp_inherit", "don", "to_task", "proc_name", "from_elem", "depth")) @lldb_type_summary(['ipc_importance_inherit *', 'ipc_importance_inherit_t']) def GetIPCImportanceInheritSummary(iii): """ describes iii object of type ipc_importance_inherit_t * """ @@ -1666,12 +1696,12 @@ def GetIPCImportanceElemSummary(iie): return out_str -@header("{: <18s} {: <18s} {: <20s}".format("iit", "task", "name")) +@header("{: <18s} {: <18s} {: <32}".format("iit", "task", "name")) @lldb_type_summary(['ipc_importance_task *']) def GetIPCImportantTaskSummary(iit): """ iit is a ipc_importance_task value object. """ - fmt = "{: <#018x} {: <#018x} {: <20s}" + fmt = "{: <#018x} {: <#018x} {: <32}" out_str='' pname = GetProcNameForTask(iit.iit_task) if hasattr(iit, 'iit_bsd_pid'): @@ -1818,8 +1848,7 @@ def GetATMHandleSummary(handle_ptr): params: handle_ptr - uint64 number stored in handle of voucher returns: str - summary of atm value """ - elem = kern.GetValueFromAddress(handle_ptr, 'atm_value *') - return GetATMValueSummary(elem) + return "???" def GetBankHandleSummary(handle_ptr): """ converts a handle value inside a voucher attribute table to bank element and returns appropriate summary. @@ -1847,8 +1876,7 @@ def GetBagofBitsHandleSummary(handle_ptr): @static_var('attr_managers',{1: GetATMHandleSummary, 2: GetIPCHandleSummary, 3: GetBankHandleSummary, 7: GetBagofBitsHandleSummary}) def GetHandleSummaryForKey(handle_ptr, key_num): """ Get a summary of handle pointer from the voucher attribute manager. - For example key 1 -> ATM and it puts atm_value_t in the handle. So summary of it would be atm value and refs etc. - key 2 -> ipc and it puts either ipc_importance_inherit_t or ipc_important_task_t. + For example key 2 -> ipc and it puts either ipc_importance_inherit_t or ipc_important_task_t. key 3 -> Bank and it puts either bank_task_t or bank_account_t. key 7 -> Bag of Bits and it puts user_data_element_t in handle. So summary of it would be Bag of Bits content and refs etc. """ @@ -2084,7 +2112,7 @@ def ShowTaskSuspenders(cmd_args=[], cmd_options={}): task = kern.GetValueFromAddress(cmd_args[0], 'task_t') if task.suspend_count == 0: - print "task {:#x} ({:s}) is not suspended".format(unsigned(task), Cast(task.bsd_info, 'proc_t').p_name) + print "task {:#x} ({:s}) is not suspended".format(unsigned(task), GetProcName(Cast(task.bsd_info, 'proc_t'))) return # If the task has been suspended by the kernel (potentially by @@ -2094,7 +2122,7 @@ def ShowTaskSuspenders(cmd_args=[], cmd_options={}): # which task did the suspension. port = task.itk_resume if not port: - print "task {:#x} ({:s}) is suspended but no resume port exists".format(unsigned(task), Cast(task.bsd_info, 'proc_t').p_name) + print "task {:#x} ({:s}) is suspended but no resume port exists".format(unsigned(task), GetProcName(Cast(task.bsd_info, 'proc_t'))) return return FindPortRights(cmd_args=[unsigned(port)], cmd_options={'-R':'S'})