1# DExTer : Debugging Experience Tester 2# ~~~~~~ ~ ~~ ~ ~~ 3# 4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5# See https://llvm.org/LICENSE.txt for license information. 6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 8import os 9from itertools import chain 10 11def in_source_file(source_files, step_info): 12 if not step_info.current_frame: 13 return False 14 if not step_info.current_location.path: 15 return False 16 if not os.path.exists(step_info.current_location.path): 17 return False 18 return any(os.path.samefile(step_info.current_location.path, f) \ 19 for f in source_files) 20 21def update_step_watches(step_info, watches, commands): 22 watch_cmds = ['DexUnreachable', 'DexExpectStepOrder'] 23 towatch = chain.from_iterable(commands[x] 24 for x in watch_cmds 25 if x in commands) 26 try: 27 # Iterate over all watches of the types named in watch_cmds 28 for watch in towatch: 29 loc = step_info.current_location 30 if (os.path.exists(loc.path) 31 and os.path.samefile(watch.path, loc.path) 32 and watch.lineno == loc.lineno): 33 result = watch.eval(step_info) 34 step_info.watches.update(result) 35 break 36 except KeyError: 37 pass 38