'corefile() -> pwnlib.elf.elf.Core
Returns a corefile for the process.
If the process is alive, attempts to create a coredump with GDB.
If the process is dead, attempts to locate the coredump created
by the kernel.'

@property
def corefile(self):

    import pwnlib.elf.corefile
    import pwnlib.gdb
    if (self.poll() is None):
        return pwnlib.gdb.corefile(self)
    finder = pwnlib.elf.corefile.CorefileFinder(self)
    if (not finder.core_path):
        self.warn(('Could    not    find    core    file    for    pid    %i' % self.pid))
        return
    core_hash = sha256file(finder.core_path)
    if (self._corefile and (self._corefile._hash == core_hash)):
        return self._corefile
    self._corefile = pwnlib.elf.corefile.Corefile(finder.core_path)
    self._corefile._hash = core_hash
    return self._corefile
