1bf215546Sopenharmony_ci#!/usr/bin/python3 2bf215546Sopenharmony_ci 3bf215546Sopenharmony_ciimport re 4bf215546Sopenharmony_ciimport sys 5bf215546Sopenharmony_ci 6bf215546Sopenharmony_cidef main(): 7bf215546Sopenharmony_ci if len(sys.argv) != 3: 8bf215546Sopenharmony_ci print("Missing arguments: ./radv_check_va.py <bo_history> <64-bit VA>") 9bf215546Sopenharmony_ci sys.exit(1) 10bf215546Sopenharmony_ci 11bf215546Sopenharmony_ci bo_history = str(sys.argv[1]) 12bf215546Sopenharmony_ci va = int(sys.argv[2], 16) 13bf215546Sopenharmony_ci 14bf215546Sopenharmony_ci va_found = False 15bf215546Sopenharmony_ci with open(bo_history) as f: 16bf215546Sopenharmony_ci for line in f: 17bf215546Sopenharmony_ci p = re.compile('timestamp=(.*), VA=(.*)-(.*), destroyed=(.*), is_virtual=(.*)') 18bf215546Sopenharmony_ci m = p.match(line) 19bf215546Sopenharmony_ci if m == None: 20bf215546Sopenharmony_ci continue 21bf215546Sopenharmony_ci 22bf215546Sopenharmony_ci va_start = int(m.group(2), 16) 23bf215546Sopenharmony_ci va_end = int(m.group(3), 16) 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci # Check if the given VA was ever valid and print info. 26bf215546Sopenharmony_ci if va >= va_start and va < va_end: 27bf215546Sopenharmony_ci print("VA found: %s" % line, end='') 28bf215546Sopenharmony_ci va_found = True 29bf215546Sopenharmony_ci if not va_found: 30bf215546Sopenharmony_ci print("VA not found!") 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ciif __name__ == '__main__': 33bf215546Sopenharmony_ci main() 34