]> git.saurik.com Git - apple/xnu.git/blame - tools/lldbmacros/counter.py
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tools / lldbmacros / counter.py
CommitLineData
c3c9b80d
A
1from memory import IterateZPerCPU
2from xnu import *
3
4@lldb_type_summary(['scalable_counter_t'])
5@header("Counter Value\n-------------")
6def GetSimpleCounter(counter):
7 """ Prints out the value of a percpu counter
8 params: counter: value - value object representing counter
9 returns: str - THe value of the counter as a string.
10 """
11 val = 0
12 for v in IterateZPerCPU(counter, "uint64_t *"):
13 val += dereference(v)
14 return str(val)
15
16@lldb_command('showcounter')
17def ShowSimpleCounter(cmd_args=None):
18 """ Show the value of a percpu counter.
19 Usage: showcounter <address of counter>
20 """
21 if not cmd_args:
22 raise ArgumentError("Please specify the address of the counter you want to read.")
23 return
24 print GetSimpleCounter(kern.GetValueFromAddress(cmd_args[0], "scalable_counter_t"))