Beispiel #1
0
def elf_symbol_program(*modules):
    prog = Program()
    for symbols in modules:
        with tempfile.NamedTemporaryFile() as f:
            f.write(create_elf_symbol_file(symbols))
            f.flush()
            prog.load_debug_info([f.name])
    return prog
Beispiel #2
0
def load_debug_info(prog: drgn.Program, dpaths: [str]) -> None:
    """
    Iterates over all the paths provided (`dpaths`) and attempts
    to load any debug information it finds. If the path provided
    is a directory, the whole directory is traversed in search
    of debug info.
    """
    for path in dpaths:
        if os.path.isfile(path):
            prog.load_debug_info([path])
        elif os.path.isdir(path):
            kos = []
            for (ppath, __, files) in os.walk(path):
                for i in files:
                    if i.endswith(".ko"):
                        kos.append(os.sep.join([ppath, i]))
            prog.load_debug_info(kos)
        else:
            print("sdb: " + path + " is not a regular file or directory")