|
17 | 17 | import re |
18 | 18 | import sys |
19 | 19 | from math import floor, log |
20 | | -from pathlib import Path |
21 | | -from subprocess import PIPE, Popen |
22 | 20 |
|
23 | 21 | __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) |
24 | 22 | __rootdir__ = os.path.dirname(__scriptdir__) |
25 | 23 | sys.path.insert(0, __rootdir__) |
26 | 24 |
|
27 | | -from tools import utils |
| 25 | +from tools import shared, utils |
28 | 26 | from tools.system_libs import DETERMINISTIC_PREFIX |
29 | 27 |
|
30 | 28 | EMSCRIPTEN_PREFIX = utils.normalize_path(utils.path_from_root()) |
@@ -233,24 +231,18 @@ def extract_comp_dir_map(text): |
233 | 231 |
|
234 | 232 | def read_dwarf_entries(wasm, options): |
235 | 233 | if options.dwarfdump_output: |
236 | | - output = Path(options.dwarfdump_output).read_bytes() |
| 234 | + output = utils.read_file(options.dwarfdump_output) |
237 | 235 | elif options.dwarfdump: |
238 | 236 | logger.debug('Reading DWARF information from %s' % wasm) |
239 | 237 | if not os.path.exists(options.dwarfdump): |
240 | | - logger.error('llvm-dwarfdump not found: ' + options.dwarfdump) |
241 | | - sys.exit(1) |
242 | | - process = Popen([options.dwarfdump, '-debug-info', '-debug-line', '--recurse-depth=0', wasm], stdout=PIPE) |
243 | | - output, err = process.communicate() |
244 | | - exit_code = process.wait() |
245 | | - if exit_code != 0: |
246 | | - logger.error('Error during llvm-dwarfdump execution (%s)' % exit_code) |
247 | | - sys.exit(1) |
| 238 | + utils.exit_with_error('llvm-dwarfdump not found: ' + options.dwarfdump) |
| 239 | + proc = shared.check_call([options.dwarfdump, '-debug-info', '-debug-line', '--recurse-depth=0', wasm], stdout=shared.PIPE) |
| 240 | + output = proc.stdout |
248 | 241 | else: |
249 | | - logger.error('Please specify either --dwarfdump or --dwarfdump-output') |
250 | | - sys.exit(1) |
| 242 | + utils.exit_with_error('Please specify either --dwarfdump or --dwarfdump-output') |
251 | 243 |
|
252 | 244 | entries = [] |
253 | | - debug_line_chunks = re.split(r"debug_line\[(0x[0-9a-f]*)\]", output.decode('utf-8')) |
| 245 | + debug_line_chunks = re.split(r"debug_line\[(0x[0-9a-f]*)\]", output) |
254 | 246 | map_stmt_list_to_comp_dir = extract_comp_dir_map(debug_line_chunks[0]) |
255 | 247 | for stmt_list, line_chunk in zip(debug_line_chunks[1::2], debug_line_chunks[2::2]): |
256 | 248 | comp_dir = map_stmt_list_to_comp_dir.get(stmt_list, '') |
|
0 commit comments