diff --git a/wally-pipelined/linux-testgen/testvector-generation/fix_mem.py b/wally-pipelined/linux-testgen/testvector-generation/fix_mem.py index d9b90009..66ff9cf0 100755 --- a/wally-pipelined/linux-testgen/testvector-generation/fix_mem.py +++ b/wally-pipelined/linux-testgen/testvector-generation/fix_mem.py @@ -1,11 +1,14 @@ #! /usr/bin/python3 -test_dir = '../' -gdbMemfileDir = '../linux-testvectors/intermediate-outputs/' -fixedMemfileDir = '../linux-testvectors/' -infiles = ['bootmemGDB.txt', 'ramGDB.txt'] -outfiles = ['bootmem.txt', 'ram.txt'] -for i in range(len(infiles)): - with open(f'{gdbMemfileDir}{infiles[i]}', 'r') as f: - with open(f'{fixedMemfileDir}{outfiles[i]}', 'w') as w: - for l in f: - w.write(f'{"".join([x[2:] for x in l.split()[:0:-1]])}\n') +import sys,os + +if len(sys.argv) != 3: + sys.exit('Error fix_mem.py expects 2 args:\n fix_mem.py ') +inputFile = sys.argv[1] +outputFile = sys.argv[2] +if not os.path.exists(inputFile): + sys.exit('Error input file '+inputFile+'not found') +print('Translating '+os.path.basename(inputFile)+' to '+os.path.basename(outputFile)) +with open(inputFile, 'r') as f: + with open(outputFile, 'w') as w: + for l in f: + w.write(f'{"".join([x[2:] for x in l.split()[:0:-1]])}\n') diff --git a/wally-pipelined/linux-testgen/testvector-generation/logBuildrootMem.sh b/wally-pipelined/linux-testgen/testvector-generation/logBuildrootMem.sh index 978311d9..a1ff4254 100755 --- a/wally-pipelined/linux-testgen/testvector-generation/logBuildrootMem.sh +++ b/wally-pipelined/linux-testgen/testvector-generation/logBuildrootMem.sh @@ -16,7 +16,8 @@ then ($customQemu -M virt -nographic -bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio -d nochain,cpu,in_asm -serial /dev/null -singlestep -gdb tcp::1235 -S 2>/dev/null >/dev/null) & riscv64-unknown-elf-gdb -x gdbinit_mem echo "Translating Mem from GDB to Questa format" - ./fix_mem.py + ./fix_mem.py "$testVecDir/intermediate-outputs/bootmemGDB.txt" "$testVecDir/bootmem.txt" + ./fix_mem.py "$testVecDir/intermediate-outputs/ramGDB.txt" "$testVecDir/ram.txt" echo "Done" echo "Creating debugging objdump of linux image"