Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
| 2 | 2 |
| 3 import argparse | 3 import argparse |
| 4 import itertools | 4 import itertools |
| 5 import os | 5 import os |
| 6 import re | 6 import re |
| 7 import subprocess | 7 import subprocess |
| 8 import sys | 8 import sys |
| 9 import tempfile | 9 import tempfile |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 help='Add a disassembler flag') | 71 help='Add a disassembler flag') |
| 72 argparser.add_argument('--filetype', default='iasm', dest='filetype', | 72 argparser.add_argument('--filetype', default='iasm', dest='filetype', |
| 73 choices=['obj', 'asm', 'iasm'], | 73 choices=['obj', 'asm', 'iasm'], |
| 74 help='Output file type. Default %(default)s.') | 74 help='Output file type. Default %(default)s.') |
| 75 argparser.add_argument('--target', default='x8632', dest='target', | 75 argparser.add_argument('--target', default='x8632', dest='target', |
| 76 choices=['x8632','arm32'], | 76 choices=['x8632','arm32'], |
| 77 help='Target architecture. Default %(default)s.') | 77 help='Target architecture. Default %(default)s.') |
| 78 argparser.add_argument('--echo-cmd', required=False, | 78 argparser.add_argument('--echo-cmd', required=False, |
| 79 action='store_true', | 79 action='store_true', |
| 80 help='Trace command that generates ICE instructions') | 80 help='Trace command that generates ICE instructions') |
| 81 argparser.add_argument('--tbc', required=False, action='store_true', | |
| 82 help='Input is textual bitcode (not .ll)') | |
| 83 argparser.add_argument('--fail', required=False, action='store_true', | |
|
Jim Stichnoth
2015/06/29 22:43:12
Bikeshedding: how about something like '--expect-f
Karl
2015/06/30 18:46:09
Done.
| |
| 84 help='Negate success of run by using LLVM not') | |
| 81 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, | 85 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, |
| 82 default=[], | 86 default=[], |
| 83 help='Remaining arguments are passed to pnacl-sz') | 87 help='Remaining arguments are passed to pnacl-sz') |
| 84 | 88 |
| 85 args = argparser.parse_args() | 89 args = argparser.parse_args() |
| 86 pnacl_bin_path = args.pnacl_bin_path | 90 pnacl_bin_path = args.pnacl_bin_path |
| 87 llfile = args.input | 91 llfile = args.input |
| 88 | 92 |
| 89 if args.llvm and args.llvm_source: | 93 if args.llvm and args.llvm_source: |
| 90 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") | 94 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") |
| 91 | 95 |
| 92 if args.llvm_source and args.no_local_syms: | 96 if args.llvm_source and args.no_local_syms: |
| 93 raise RuntimeError("Can't specify both '--llvm-source' and " + | 97 raise RuntimeError("Can't specify both '--llvm-source' and " + |
| 94 "'--no-local-syms'") | 98 "'--no-local-syms'") |
| 95 | 99 |
| 100 if args.llvm_source and args.tbc: | |
| 101 raise RuntimeError("Can't specify '--tbc' and '--llvm-source'") | |
|
Jim Stichnoth
2015/06/29 22:43:12
"Can't specify both ..." for consistency?
Karl
2015/06/30 18:46:09
Done.
| |
| 102 | |
| 103 if args.llvm and args.tbc: | |
| 104 raise RuntimeError("Can't specify '--tbc' and '--llvm'") | |
| 105 | |
| 96 cmd = [] | 106 cmd = [] |
| 97 if not args.llvm_source: | 107 if args.tbc: |
| 108 cmd = [os.path.join(pnacl_bin_path, 'pnacl-bcfuzz'), llfile, | |
| 109 '-bitcode-as-text', '-output', '-', '|'] | |
| 110 elif not args.llvm_source: | |
| 98 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|', | 111 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|', |
| 99 os.path.join(pnacl_bin_path, 'pnacl-freeze')] | 112 os.path.join(pnacl_bin_path, 'pnacl-freeze')] |
| 100 if not args.no_local_syms: | 113 if not args.no_local_syms: |
| 101 cmd += ['--allow-local-symbol-tables'] | 114 cmd += ['--allow-local-symbol-tables'] |
| 102 cmd += ['|'] | 115 cmd += ['|'] |
| 116 if args.fail: | |
| 117 cmd += [os.path.join(pnacl_bin_path, 'not')] | |
| 103 cmd += [args.pnacl_sz] | 118 cmd += [args.pnacl_sz] |
| 104 cmd += ['--target', args.target] | 119 cmd += ['--target', args.target] |
| 105 if args.insts: | 120 if args.insts: |
| 106 # If the tests are based on '-verbose inst' output, force | 121 # If the tests are based on '-verbose inst' output, force |
| 107 # single-threaded translation because dump output does not get | 122 # single-threaded translation because dump output does not get |
| 108 # reassembled into order. | 123 # reassembled into order. |
| 109 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0'] | 124 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0'] |
| 110 if not args.llvm_source: | 125 if not args.llvm_source: |
| 111 cmd += ['--bitcode-format=pnacl'] | 126 cmd += ['--bitcode-format=pnacl'] |
| 112 if not args.no_local_syms: | 127 if not args.no_local_syms: |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 140 [asm_temp.name]) | 155 [asm_temp.name]) |
| 141 | 156 |
| 142 stdout_result = shellcmd(cmd, echo=args.echo_cmd) | 157 stdout_result = shellcmd(cmd, echo=args.echo_cmd) |
| 143 if not args.echo_cmd: | 158 if not args.echo_cmd: |
| 144 sys.stdout.write(stdout_result) | 159 sys.stdout.write(stdout_result) |
| 145 if asm_temp: | 160 if asm_temp: |
| 146 os.remove(asm_temp.name) | 161 os.remove(asm_temp.name) |
| 147 | 162 |
| 148 if __name__ == '__main__': | 163 if __name__ == '__main__': |
| 149 main() | 164 main() |
| OLD | NEW |