3 Provide access to the page flags known by crash.
4 Copyright 2014 Cray Inc. All Rights Reserved
6 The data is gathered from the 'kmem -g' command.
9 from pykdump.API import *
15 # Note: This class should probably be abstracted somewhere as a
16 # bit or bitmask class, but since we don't have that yet, just
17 # create a new class here.
18 """Represent a flag as a bit mask and a shift value."""
19 def __init__(self, name, shift_val):
21 self.shift = int(shift_val)
22 self.mask = 1 << self.shift
29 """Extract the machine-specific page flags from crash.
31 When instantiated, this class produces an object with data members
32 for each kernel page flag that crash knows about, based on the kernel
33 version. Each page flag is an instance of class PageFlag. An example
36 page = readSU('struct page', page_addr)
38 if page.flags & kpf.PG_slab.mask:
43 """Extract the page flags from the crash 'kmem -g' command."""
44 for line in exec_crash_command('kmem -g').splitlines():
48 # PG_waiters 1 0000002
51 if len(fields) < 3 or fields[0][0:3] != 'PG_': continue
54 shift = int(fields[1])
55 self.__dict__[name] = PageFlag(name, shift)
57 # --------------------------------------------------------------------------
59 # Create a shared instances of the above classes.
61 crashlib.cid.pgflags = MachPageFlags()