3 Provide access to machine-dependent data.
4 Copyright 2014, 2017 Cray Inc. All Rights Reserved
7 from pykdump.API import *
12 """Provide access to the crash machdep_table.
14 The data is collected by parsing the output of the 'help -m' command.
18 """Extract machine-dependent data from crash.
20 Initialize the table of machine dependent information by parsing
21 the output of the 'help -m' command. This only extracts
24 Each item extracted is made available as an instance attribute.
27 # crash 'help -m' doesn't use prefixes on numbers, so we must
28 # know what number base is in use for each numeric field.
30 'bits' : 10, 'flags' : 16, 'hz' : 10, 'identity_map_base' : 16,
31 'kvbase' : 16, 'last_pgd_read' : 16, 'last_pmd_read' : 16,
32 'last_ptbl_read' : 16, 'machspec' : 16, 'max_physmem_bits' : 10,
33 'memsize' : 10, 'mhz' : 10, 'modules_vaddr' : 16, 'nr_irqs' : 10,
34 'page_offset' : 16, 'pagemask' : 16, 'pageshift' : 10,
35 'pagesize' : 10, 'pgd' : 16, 'pmd' : 16, 'ptbl' : 16,
36 'ptrs_per_pgd' : 10, 'section_size_bits' : 10,
37 'sections_per_root' : 10, 'stacksize' : 10, 'userspace_top' : 16,
38 'vmalloc_end' : 16, 'vmalloc_start_addr' : 16, 'vmemmap_end' : 16,
42 if sys_info.machine in ("x86_64", "k1om", "x86"):
43 # additional x86_64 fields:
44 # Attic: 'last_pml4_read': 16, 'last_umpl_read': 16,
45 # 'umpl': 16, 'pml4': 16
47 'irq_eframe_link' : 10, 'irqstack' : 16,
48 'page_protnone' : 16, 'phys_base' : 16,
49 'thread_return' : 16, 'vsyscall_page' : 16,
51 fieldBase.update(x86_64_fields)
52 elif sys_info.machine == 'aarch64':
53 # no additional aarch64 field yet
56 raise crashlib.cid.ParseError(
57 'Invalid machine type {0}.'.format(sys_info.machine))
59 expected_key_count = len(fieldBase)
61 for line in exec_crash_command('help -m').splitlines():
63 # flags: 30400209 (KSYMS_START|MACHDEP_BT_TEXT|VM_2_6_11|VMEMMAP|FRAMESIZE_DEBUG|FRAMEPOINTER)
64 # kvbase: ffff880000000000
65 # identity_map_base: ffff880000000000
68 # pagemask: fffffffffffff000
73 # memsize: 68694994944 (0xffe8a7000)
76 # Only use the first value after the field name and
77 # only for selected fields.
79 if len(parts) < 2: continue
81 key = parts[0].rstrip(':')
82 base = fieldBase.get(key, None)
85 self.__dict__[key] = int(parts[1], base)
87 # If some versions of crash or the kernel don't have all the
88 # fields, this check code may need to be removed or modified.
89 if len(self.__dict__.keys()) != expected_key_count:
90 raise crashlib.cid.ParseError(
91 'Expected {:d}, but parsed {:d} entries.'.format(
92 expected_key_count, len(self.__dict__.keys())))
94 # --------------------------------------------------------------------------
96 # Create a shared instances.
98 crashlib.cid.mdtbl = MachDepInfo()