1from xnu import * 2 3@lldb_type_summary(['workload_config_entry_t *']) 4@header("{0: <20s} {1: <40s} {2: <18s} {3: <18s}".format("workload", "id", "default phase", "phases")) 5def GetWorkloadConfigSummary(workload): 6 """ Summarizes workload_config_entry structure 7 params: workload: value - value object representing workload_config_entry 8 returns: str - summary of the workload object 9 """ 10 format_string = '{0: <#020x} {1: <40s} {2: <#018x} {2: <#018x}' 11 return format_string.format(workload, str(workload.wce_id), workload.wce_default, workload.wce_phases) 12 13 14@lldb_type_summary(['workload_phase_entry_t *']) 15@header("{0: <20s} {1: <25s} {2: <10s} {3: <10s} {4: <10s} {5: <20s}".format("phase", "id", "flags", "cflags", "tflags", "criticality offset")) 16def GetWorkloadPhaseSummary(phase): 17 """ Summarizes workload_phase_entry structure 18 params: phase: value - value object representing workload_phase_entry 19 returns: str - summary of the workload phase object 20 """ 21 22 format_string = '{0: <#020x} {1: <25s} {2: <#010x} {3: <#010x} {4: <#010x} {4: <20d} ' 23 return format_string.format(phase, str(phase.wpe_phase), phase.wpe_config.wc_flags, phase.wpe_config.wc_create_flags, phase.wpe_config.wc_thread_group_flags, phase.wpe_config.wc_criticality_offset) 24 25# Macro: showallworkloadconfig 26 27@lldb_command('showallworkloadconfig') 28def ShowAllWorkloadConfig(cmd_args=None, cmd_options={}): 29 """ Routine to print the all workload configurations. 30 Usage: showallworkloadconfig 31 """ 32 33 print(GetWorkloadConfigSummary.header) 34 table = kern.globals.workload_config_boot.wlcc_hashtbl 35 mask = kern.globals.workload_config_boot.wlcc_hash_mask 36 37 if table != 0: 38 for i in range(mask + 1): 39 for entry in IterateListEntry(table[i], 'wce_link'): 40 print(GetWorkloadConfigSummary(entry)) 41 42# EndMacro: showallworkloadconfig 43 44 45# Macro: showworkloadconfig 46 47@lldb_command('showworkloadconfig', 'F:') 48def ShowWorkloadConfig(cmd_args=None, cmd_options={}): 49 """ Routine to print a summary listing of given workload config 50 Usage: showworkloadconfig <address of workload config> 51 or : showworkloadconfig -F <workload config id> 52 """ 53 54 if "-F" in cmd_options: 55 print(GetWorkloadConfigSummary.header) 56 table = kern.globals.workload_config_boot.wlcc_hashtbl 57 mask = kern.globals.workload_config_boot.wlcc_hash_mask 58 59 if table != 0: 60 for i in range(mask + 1): 61 for entry in IterateListEntry(table[i], 'wce_link'): 62 if cmd_options['-F'] == str(entry.wce_id): 63 print(GetWorkloadConfigSummary(entry)) 64 return 65 else: 66 if not cmd_args: 67 raise ArgumentError("Invalid arguments passed.") 68 entry = kern.GetValueFromAddress(cmd_args[0], 'workload_config_entry_t *') 69 print(GetWorkloadConfigSummary.header) 70 print(GetWorkloadConfigSummary(entry)) 71 72# EndMacro: showworkloadconfig 73 74 75# Macro: showworkloadconfigphases 76 77@lldb_command('showworkloadconfigphases') 78def ShowWorkloadConfigPhases(cmd_args=None, cmd_options={}): 79 """ Routine to print the workload configuration phases of the specified workload config. 80 Usage: showworkloadconfigphases <workload config> 81 """ 82 83 if not cmd_args: 84 raise ArgumentError("Invalid arguments passed.") 85 86 print(GetWorkloadPhaseSummary.header) 87 88 entry = kern.GetValueFromAddress(cmd_args[0], 'workload_config_entry_t *') 89 for phase in IterateListEntry(entry.wce_phases, 'wpe_link'): 90 print(GetWorkloadPhaseSummary(phase)) 91 92# EndMacro: showworkloadconfigphases 93 94