Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / postmortem / FreeBSDKernel / tools / copy-sparse.py
blob69da526b4f804d045a889632bff349e145d3f67b
1 #!/usr/bin/env python
3 import argparse
4 import re
5 import sys
8 def main():
9 argp = argparse.ArgumentParser()
10 argp.add_argument("infile", type=argparse.FileType("rb"), help="Input vmcore file")
11 argp.add_argument(
12 "outfile", type=argparse.FileType("wb"), help="Output vmcore file"
14 args = argp.parse_args()
16 inf = args.infile
17 outf = args.outfile
18 line_re = re.compile(r"^% RD: (\d+) (\d+)")
20 # copy the first chunk that usually includes ELF headers
21 # (not output by patched libfbsdvmcore since libelf reads this)
22 outf.write(inf.read(1024))
24 for l in sys.stdin:
25 m = line_re.match(l)
26 if m is None:
27 continue
28 offset, size = [int(x) for x in m.groups()]
30 inf.seek(offset)
31 outf.seek(offset)
32 outf.write(inf.read(size))
35 if __name__ == "__main__":
36 main()