forked from Github_Repos/cvw
		
	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:
		
							parent
							
								
									008089b470
								
							
						
					
					
						commit
						54c5f7f607
					
				@ -41,7 +41,7 @@ then
 | 
			
		||||
    -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 \
 | 
			
		||||
    -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -81,7 +81,7 @@ def WhatAddrSC(text, Regs):
 | 
			
		||||
    Src = Src.strip(')').strip()
 | 
			
		||||
    return Regs[Src]
 | 
			
		||||
 | 
			
		||||
def PrintInstr(instr, fp):
 | 
			
		||||
def PrintInstr(instr):
 | 
			
		||||
    if instr[2] == None:
 | 
			
		||||
        return
 | 
			
		||||
    ChangedRegisters = instr[4]
 | 
			
		||||
@ -107,28 +107,27 @@ def PrintInstr(instr, fp):
 | 
			
		||||
    #print(instr)
 | 
			
		||||
 | 
			
		||||
    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):
 | 
			
		||||
            fp.write(' GPR {}'.format(GPR))
 | 
			
		||||
            outString+=' GPR {}'.format(GPR)
 | 
			
		||||
        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'):
 | 
			
		||||
            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):
 | 
			
		||||
            fp.write(' CSR {}'.format(CSRStr))
 | 
			
		||||
            outString+=' CSR {}'.format(CSRStr)
 | 
			
		||||
    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):
 | 
			
		||||
            fp.write(' GPR {}'.format(GPR))
 | 
			
		||||
            outString+=' GPR {}'.format(GPR)
 | 
			
		||||
        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'):
 | 
			
		||||
            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):
 | 
			
		||||
            fp.write(' CSR {}'.format(CSRStr))
 | 
			
		||||
    fp.write('\n')
 | 
			
		||||
            outString+=' CSR {}'.format(CSRStr)
 | 
			
		||||
    outString+='\n'
 | 
			
		||||
    return outString
 | 
			
		||||
 | 
			
		||||
# =========
 | 
			
		||||
# Main Code
 | 
			
		||||
@ -154,6 +153,8 @@ lines = []
 | 
			
		||||
interrupts=open(interruptFname,'w')
 | 
			
		||||
interrupts.close()
 | 
			
		||||
 | 
			
		||||
prevInstrOutString=''
 | 
			
		||||
currInstrOutString=''
 | 
			
		||||
for line in fileinput.input('-'):
 | 
			
		||||
    if line.startswith('riscv_cpu_do_interrupt'):
 | 
			
		||||
        with open(interruptFname,'a') as interrupts:
 | 
			
		||||
@ -219,11 +220,16 @@ for line in fileinput.input('-'):
 | 
			
		||||
 | 
			
		||||
        lines.clear()
 | 
			
		||||
        #instructions.append(MoveInstrToRegWriteLst)
 | 
			
		||||
        PrintInstr(MoveInstrToRegWriteLst, sys.stdout)
 | 
			
		||||
        numInstrs +=1
 | 
			
		||||
        if (numInstrs % 1e5 == 0):
 | 
			
		||||
            sys.stderr.write('GDB trace parser reached '+str(numInstrs/1.0e6)+' million instrs.\n')
 | 
			
		||||
            sys.stderr.flush()
 | 
			
		||||
 | 
			
		||||
        prevInstrOutString = currInstrOutString
 | 
			
		||||
        currInstrOutString = PrintInstr(MoveInstrToRegWriteLst)
 | 
			
		||||
        # Remove duplicates
 | 
			
		||||
        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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user