]> git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/pgtrace.py
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tools / lldbmacros / pgtrace.py
1 #! /usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 from xnu import *
5
6 # Macro: pgtrace
7 @lldb_command('showpgtrace')
8 def ShowPgtrace(cmd_args=None, cmd_options={}):
9 """ Display pgtrace buffer contents
10 Usage: showpgtrace
11 """
12
13 max_entry = kern.globals.pgtrace.size
14 rd_idx = kern.globals.pgtrace.rdidx
15 wr_idx = kern.globals.pgtrace.wridx
16
17 print "-"*80
18 print "rd_idx=%d wr_idx=%d num_entries=%d max_entry=%d" % (rd_idx, wr_idx, wr_idx-rd_idx, max_entry)
19 print "-"*80
20
21 rw_str = { GetEnumValue('pgtrace_rw_t::PGTRACE_RW_LOAD'): "R",
22 GetEnumValue('pgtrace_rw_t::PGTRACE_RW_STORE'): "W",
23 GetEnumValue('pgtrace_rw_t::PGTRACE_RW_PREFETCH'): "P" }
24
25 while rd_idx != wr_idx:
26 clipped_idx = rd_idx % max_entry
27 entry = kern.globals.pgtrace.logs + sizeof('log_t') * clipped_idx
28 entry = kern.GetValueFromAddress(entry, 'log_t *')
29
30 entry_str = "[%d] id=%lu time=%lu %s " % (clipped_idx, entry.id, entry.res.rr_time, rw_str[int(entry.res.rr_rw)])
31
32 for i in range(entry.res.rr_num):
33 entry_str += "%x=%x " % (entry.res.rr_addrdata[i].ad_addr, entry.res.rr_addrdata[i].ad_data)
34
35 print entry_str
36
37 rd_idx += 1
38 # EndMacro