deprecate remove_dup.awk in favor of expanding parseGDBtoTrace.py to internally remove duplicates; this way the instruction counts in traps.txt are hopefully now in sync with the line numbers of all.txt

This commit is contained in:
bbracker 2022-04-07 19:43:22 -07:00
parent 008089b470
commit 54c5f7f607
3 changed files with 26 additions and 40 deletions

View File

@ -41,7 +41,7 @@ then
-bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \ -bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \
-singlestep -rtc clock=vm -icount shift=0,align=off,sleep=on,rr=replay,rrfile=$recordFile \ -singlestep -rtc clock=vm -icount shift=0,align=off,sleep=on,rr=replay,rrfile=$recordFile \
-d nochain,cpu,in_asm,int \ -d nochain,cpu,in_asm,int \
2>&1 >./qemu-serial | ./parseQEMUtoGDB.py | ./parseGDBtoTrace.py $trapsFile | ./remove_dup.awk > $traceFile) 2>&1 >./qemu-serial | ./parseQEMUtoGDB.py | ./parseGDBtoTrace.py $trapsFile > $traceFile)
./filterTrapsToInterrupts.py $tvDir ./filterTrapsToInterrupts.py $tvDir

View File

@ -81,7 +81,7 @@ def WhatAddrSC(text, Regs):
Src = Src.strip(')').strip() Src = Src.strip(')').strip()
return Regs[Src] return Regs[Src]
def PrintInstr(instr, fp): def PrintInstr(instr):
if instr[2] == None: if instr[2] == None:
return return
ChangedRegisters = instr[4] ChangedRegisters = instr[4]
@ -107,28 +107,27 @@ def PrintInstr(instr, fp):
#print(instr) #print(instr)
if (HUMAN_READABLE == True): if (HUMAN_READABLE == True):
fp.write('{:016x} {:08x} {:25s}'.format(instr[0], instr[1], instr[2])) outString='{:016x} {:08x} {:25s}'.format(instr[0], instr[1], instr[2])
if(len(GPR) != 0): if(len(GPR) != 0):
fp.write(' GPR {}'.format(GPR)) outString+=' GPR {}'.format(GPR)
if(instr[3] == 'load' or instr[3] == 'lr'): if(instr[3] == 'load' or instr[3] == 'lr'):
fp.write(' MemR {:016x} {:016x} {:016x}'.format(instr[5], 0, instr[7])) outString+=' MemR {:016x} {:016x} {:016x}'.format(instr[5], 0, instr[7])
if(instr[3] == 'store'): if(instr[3] == 'store'):
fp.write('\t\t\t MemW {:016x} {:016x} {:016x}'.format(instr[5], instr[6], 0)) outString+='\t\t\t MemW {:016x} {:016x} {:016x}'.format(instr[5], instr[6], 0)
if(len(CSR) != 0): if(len(CSR) != 0):
fp.write(' CSR {}'.format(CSRStr)) outString+=' CSR {}'.format(CSRStr)
else: else:
fp.write('{:x} {:x} {:s}'.format(instr[0], instr[1], instr[2].replace(' ', '_'))) outString='{:x} {:x} {:s}'.format(instr[0], instr[1], instr[2].replace(' ', '_'))
if(len(GPR) != 0): if(len(GPR) != 0):
fp.write(' GPR {}'.format(GPR)) outString+=' GPR {}'.format(GPR)
if(instr[3] == 'load' or instr[3] == 'lr'): if(instr[3] == 'load' or instr[3] == 'lr'):
fp.write(' MemR {:x} {:x} {:x}'.format(instr[5], 0, instr[7])) outString+=' MemR {:x} {:x} {:x}'.format(instr[5], 0, instr[7])
if(instr[3] == 'store'): if(instr[3] == 'store'):
fp.write(' MemW {:x} {:x} {:x}'.format(instr[5], instr[6], 0)) outString+=' MemW {:x} {:x} {:x}'.format(instr[5], instr[6], 0)
if(len(CSR) != 0): if(len(CSR) != 0):
fp.write(' CSR {}'.format(CSRStr)) outString+=' CSR {}'.format(CSRStr)
fp.write('\n') outString+='\n'
return outString
# ========= # =========
# Main Code # Main Code
@ -154,6 +153,8 @@ lines = []
interrupts=open(interruptFname,'w') interrupts=open(interruptFname,'w')
interrupts.close() interrupts.close()
prevInstrOutString=''
currInstrOutString=''
for line in fileinput.input('-'): for line in fileinput.input('-'):
if line.startswith('riscv_cpu_do_interrupt'): if line.startswith('riscv_cpu_do_interrupt'):
with open(interruptFname,'a') as interrupts: with open(interruptFname,'a') as interrupts:
@ -219,11 +220,16 @@ for line in fileinput.input('-'):
lines.clear() lines.clear()
#instructions.append(MoveInstrToRegWriteLst) #instructions.append(MoveInstrToRegWriteLst)
PrintInstr(MoveInstrToRegWriteLst, sys.stdout)
numInstrs +=1 prevInstrOutString = currInstrOutString
if (numInstrs % 1e5 == 0): currInstrOutString = PrintInstr(MoveInstrToRegWriteLst)
sys.stderr.write('GDB trace parser reached '+str(numInstrs/1.0e6)+' million instrs.\n') # Remove duplicates
sys.stderr.flush() if (PreviousInstr[0] != CurrentInstr[0]) and (currInstrOutString != None):
sys.stdout.write(currInstrOutString)
numInstrs += 1
if (numInstrs % 1e5 == 0):
sys.stderr.write('GDB trace parser reached '+str(numInstrs/1.0e6)+' million instrs.\n')
sys.stderr.flush()
lineNum += 1 lineNum += 1

View File

@ -1,20 +0,0 @@
#!/usr/bin/awk -f
BEGIN{
old = "first"
}
{
if($1 != old){
if(old != "first"){
print oldAll
}
}
old=$1
oldAll=$0
}
END{
print oldAll
}