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