def setup_page_type(cls, gdbtype: gdb.Type) -> None: # TODO: should check config, but that failed to work on ppc64, hardcode # 64k for now if crash.current_target().arch.name() == "powerpc:common64": cls.PAGE_SHIFT = 16 # also a config cls.directmap_base = 0xc000000000000000 cls.sparsemem = True cls.sparsemem_vmemmap = False cls.sparsemem_extreme = False cls.SECTION_SIZE_BITS = 24 cls.PAGE_SIZE = 1 << cls.PAGE_SHIFT cls.PAGE_MASK = ~(cls.PAGE_SIZE - 1) cls.slab_cache_name = find_member_variant(gdbtype, ['slab_cache', 'lru']) cls.slab_page_name = find_member_variant(gdbtype, ['slab_page', 'lru']) cls.compound_head_name = find_member_variant( gdbtype, ['compound_head', 'first_page']) if not hasattr(cls, 'vmemmap'): cls.vmemmap = gdb.Value(cls.vmemmap_base).cast(gdbtype.pointer()) if struct_has_member(gdbtype, 'page_type'): cls._is_buddy = cls.__is_buddy_page_type else: cls._is_buddy = cls.__is_buddy_mapcount cls.setup_page_type_done = True if cls.setup_pageflags_done and not cls.setup_pageflags_finish_done: cls.setup_pageflags_finish()
def __init__(self) -> None: target = crash.current_target() try: target.set_fetch_registers(self._fetch_registers()) except AttributeError: raise NotImplementedError( "No fetch_registers callback defined") from None
def __init__(self, roots: PathSpecifier = None, vmlinux_debuginfo: PathSpecifier = None, module_path: PathSpecifier = None, module_debuginfo_path: PathSpecifier = None, verbose: bool = False, debug: bool = False) -> None: self.findmap: Dict[str, Dict[Any, Any]] = dict() self.modules_order: Dict[str, Dict[str, str]] = dict() obj = gdb.objfiles()[0] if not obj.filename: raise RuntimeError("loaded objfile has no filename???") kernel = os.path.basename(obj.filename) self.kernel = kernel self.version = self.extract_version() self._setup_roots(roots, verbose) self._setup_vmlinux_debuginfo(vmlinux_debuginfo, verbose) self._setup_module_path(module_path, verbose) self._setup_module_debuginfo_path(module_debuginfo_path, verbose) # We need separate debuginfo. Let's go find it. path_list = [] build_id_path = self.build_id_path(obj) if build_id_path: path_list.append(build_id_path) path_list += self.vmlinux_debuginfo if not obj.has_symbols(): print("Loading debug symbols for vmlinux") for path in path_list: try: obj.add_separate_debug_file(path) if obj.has_symbols(): break except gdb.error: pass if not obj.has_symbols(): raise CrashKernelError( "Couldn't locate debuginfo for {}".format(kernel)) self.vermagic = self.extract_vermagic() archname = obj.architecture.name() try: archclass = crash.arch.get_architecture(archname) except RuntimeError as e: raise CrashKernelError(str(e)) self.arch = archclass() self.target = crash.current_target() self.vmcore = self.target.kdump self.crashing_thread: Optional[gdb.InferiorThread] = None
def numa_node_id(cpu: int) -> int: """ Return the NUMA node ID for a given CPU Args: cpu: The CPU number to obtain the NUMA node ID Returns: :obj:`int`: The NUMA node ID for the specified CPU. """ if crash.current_target().arch.name() == "powerpc:common64": return int(symvals.numa_cpu_lookup_table[cpu]) return int(get_percpu_var(symbols.numa_node, cpu))
def __init__(self) -> None: try: target = crash.current_target() self.context = target.kdump.get_addrxlat_ctx() self.system = target.kdump.get_addrxlat_sys() except AttributeError: self.context = TranslationContext() self.system = addrxlat.System() self.system.os_init(self.context, arch=utsname.machine, type=addrxlat.OS_LINUX) self.is_non_auto = False xlatmap = self.system.get_map(addrxlat.SYS_MAP_MACHPHYS_KPHYS) for addr_range in xlatmap: if addr_range.meth == addrxlat.SYS_METH_NONE: continue meth = self.system.get_meth(addr_range.meth) if meth.kind != addrxlat.LINEAR or meth.off != 0: self.is_non_auto = True break