]>
Commit | Line | Data |
---|---|---|
c3c9b80d A |
1 | from memory import IterateZPerCPU |
2 | from xnu import * | |
3 | ||
4 | @lldb_type_summary(['scalable_counter_t']) | |
5 | @header("Counter Value\n-------------") | |
6 | def 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') | |
17 | def 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")) |