Beispiel #1
0
    def __init__(self,
                 kernel_exec=None,
                 vmcore=None,
                 kernelpath=None,
                 searchpath=None,
                 debug=False):
        print("crash-python initializing...")
        if searchpath is None:
            searchpath = []

        autoload_submodules('crash.cache')
        autoload_submodules('crash.subsystem')
        autoload_submodules('crash.commands')

        self.searchpath = searchpath

        if not kernel_exec:
            return

        error = gdb.execute("file {}".format(kernel_exec), to_string=True)

        try:
            list_type = gdb.lookup_type('struct list_head')
        except gdb.error as e:
            load_debuginfo(searchpath, gdb.objfiles()[0], kernelpath)
            try:
                list_type = gdb.lookup_type('struct list_head')
            except gdb.error as e:
                raise RuntimeError(
                    "Couldn't locate debuginfo for {}".format(kernel_exec))

        self.target = crash.kdump.target.Target(vmcore, debug)
        load_modules(self.searchpath)
Beispiel #2
0
    def __init__(self,
                 kernel: CrashKernel,
                 verbose: bool = False,
                 debug: bool = False) -> None:
        print("crash-python initializing...")
        self.kernel = kernel

        autoload_submodules('crash.cache')
        autoload_submodules('crash.subsystem')
        autoload_submodules('crash.commands')

        try:
            self.kernel.setup_tasks()
            self.kernel.load_modules(verbose=verbose, debug=debug)
        except CrashKernelError as e:
            print(str(e))
            print("Further debugging may not be possible.")
            return

        if self.kernel.crashing_thread:
            try:
                result = gdb.execute("thread {}".format(
                    self.kernel.crashing_thread.num),
                                     to_string=True)
                if debug:
                    print(result)
            except gdb.error as e:
                print("Error while switching to crashed thread: {}".format(
                    str(e)))
                print("Further debugging may not be possible.")
                return

            print("Backtrace from crashing task (PID {:d}):".format(
                self.kernel.crashing_thread.ptid[1]))
            gdb.execute("where")
Beispiel #3
0
    def __init__(self,
                 kernel_exec=None,
                 vmcore=None,
                 kernelpath=None,
                 searchpath=None,
                 debug=False):
        self.vmcore_filename = vmcore

        print("crash-python initializing...")
        if searchpath is None:
            searchpath = []

        if kernel_exec:
            self.kernel = crash.kernel.CrashKernel(kernel_exec, searchpath)
            self.kernel.attach_vmcore(vmcore, debug)
            self.kernel.open_kernel()

        autoload_submodules('crash.cache')
        autoload_submodules('crash.subsystem')
        autoload_submodules('crash.commands')

        if kernel_exec:
            self.kernel.setup_tasks()
            self.kernel.load_modules(searchpath)
Beispiel #4
0
    def __init__(self, kernel_exec=None, vmcore=None, kernelpath=None,
                 searchpath=None, debug=False):
        print("crash-python initializing...")
        if searchpath is None:
            searchpath = []

        autoload_submodules('crash.cache')
        autoload_submodules('crash.subsystem')
        autoload_submodules('crash.commands')

        self.searchpath = searchpath

        if not kernel_exec:
            return

        try:
            kdump = kdumpfile(vmcore)
        except OSErrorException as e:
            raise RuntimeError(str(e))

        kaslr_off = long(
            kdump.attr.get("linux.vmcoreinfo.lines.KERNELOFFSET", "0"),
            base=16)

        error = gdb.execute("exec-file {}".format(kernel_exec), to_string=True)
        tinfo = gdb.execute("info target", to_string=True)
        args=""
        textaddr = 0
        in_exec = False
        for line in tinfo.splitlines():
            if line.startswith((" ", "\t")):
                if not in_exec:
                    continue
                try:
                    (addrs, sect) = line.strip().split(" is ")
                except ValueError:
                    continue
                (start, end) = addrs.split(" - ")
                sect = sect.split(' ')[0]
                startaddr = long(start, base=0) + kaslr_off
                if sect == ".text":
                    textaddr = startaddr
                    args += " 0x{:x}".format(startaddr)
                elif startaddr >= textaddr:
                    args += " -s {} 0x{:x}".format(sect, startaddr)
            elif line.startswith("Local exec file:"):
                in_exec = True
            elif not line.startswith("warning: "):
                in_exec = False

        error = gdb.execute("add-symbol-file {}{}".format(kernel_exec, args), to_string=True)

        try:
            list_type = gdb.lookup_type('struct list_head')
        except gdb.error as e:
            load_debuginfo(searchpath, gdb.objfiles()[0], kernelpath)
            try:
                list_type = gdb.lookup_type('struct list_head')
            except gdb.error as e:
                raise RuntimeError("Couldn't locate debuginfo for {}".format(kernel_exec))

        self.target = crash.kdump.target.Target(kdump, debug)
        load_modules(self.searchpath)
Beispiel #5
0
def discover():
    autoload_submodules('crash.cache')
Beispiel #6
0
def discover() -> None:
    autoload_submodules('crash.cache')