2016-05-21 16:38:29 +03:00
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
|
|
|
|
import criu_coredump
|
|
|
|
|
2021-09-05 21:34:00 +01:00
|
|
|
|
2016-05-21 16:38:29 +03:00
|
|
|
def coredump(opts):
|
2021-09-05 21:34:00 +01:00
|
|
|
generator = criu_coredump.coredump_generator()
|
|
|
|
cores = generator(os.path.realpath(opts['in']))
|
|
|
|
for pid in cores:
|
|
|
|
if opts['pid'] and pid != opts['pid']:
|
|
|
|
continue
|
2021-09-05 22:37:26 +01:00
|
|
|
with open(os.path.realpath(opts['out']) + "/core." + str(pid), 'wb+') as f:
|
2021-09-05 21:34:00 +01:00
|
|
|
cores[pid].write(f)
|
2016-05-21 16:38:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-09-05 21:34:00 +01:00
|
|
|
desc = 'CRIU core dump'
|
|
|
|
parser = argparse.ArgumentParser(description=desc,
|
|
|
|
formatter_class=argparse.RawTextHelpFormatter)
|
|
|
|
|
|
|
|
parser.add_argument('-i',
|
|
|
|
'--in',
|
|
|
|
default='.',
|
|
|
|
help='directory where to get images from')
|
|
|
|
parser.add_argument('-p',
|
|
|
|
'--pid',
|
|
|
|
type=int,
|
|
|
|
help='generate coredump for specific pid(all pids py default)')
|
|
|
|
parser.add_argument('-o',
|
|
|
|
'--out',
|
|
|
|
default='.',
|
|
|
|
help='directory to write coredumps to')
|
|
|
|
|
|
|
|
opts = vars(parser.parse_args())
|
|
|
|
|
|
|
|
coredump(opts)
|
|
|
|
|
2016-05-21 16:38:29 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2021-09-05 21:34:00 +01:00
|
|
|
main()
|