1*699cd480SApple OSS Distributionsfrom __future__ import absolute_import, print_function 2*699cd480SApple OSS Distributions 3*699cd480SApple OSS Distributionsfrom memory import IterateZPerCPU 4*699cd480SApple OSS Distributionsfrom xnu import * 5*699cd480SApple OSS Distributions 6*699cd480SApple OSS Distributions@lldb_type_summary(['scalable_counter_t']) 7*699cd480SApple OSS Distributions@header("Counter Value\n-------------") 8*699cd480SApple OSS Distributionsdef GetSimpleCounter(counter): 9*699cd480SApple OSS Distributions """ Prints out the value of a percpu counter 10*699cd480SApple OSS Distributions params: counter: value - value object representing counter 11*699cd480SApple OSS Distributions returns: str - THe value of the counter as a string. 12*699cd480SApple OSS Distributions """ 13*699cd480SApple OSS Distributions val = 0 14*699cd480SApple OSS Distributions for v in IterateZPerCPU(counter): 15*699cd480SApple OSS Distributions val += dereference(v) 16*699cd480SApple OSS Distributions return str(val) 17*699cd480SApple OSS Distributions 18*699cd480SApple OSS Distributions@lldb_command('showcounter') 19*699cd480SApple OSS Distributionsdef ShowSimpleCounter(cmd_args=None): 20*699cd480SApple OSS Distributions """ Show the value of a percpu counter. 21*699cd480SApple OSS Distributions Usage: showcounter <address of counter> 22*699cd480SApple OSS Distributions """ 23*699cd480SApple OSS Distributions if not cmd_args: 24*699cd480SApple OSS Distributions raise ArgumentError("Please specify the address of the counter you want to read.") 25*699cd480SApple OSS Distributions 26*699cd480SApple OSS Distributions print(GetSimpleCounter(kern.GetValueFromAddress(cmd_args[0], "scalable_counter_t"))) 27