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