import os import re import gdb import time import common_functions as cf def exit_handler(event): global nosalir nosalir=False print(str("event type: exit")) try: print("exit code: {}".format(str(event.exit_code))) except Exception as err: err_str = "ERROR: {}".format(str(err)) print(err_str) """ Handler that will put a breakpoint on the kernel after signal """ def selectrd(): linea= cf.execute_command(gdb=gdb, to_execute="x/1i $pc") print (linea)#+"-"+str(len(linea))+"-"+linea[0]) print ("============") lista=re.findall(r"R(\d+)", linea[0]) #Si no hay nexti listareg=[" R{} ".format(x) for x in lista] strlistareg="info registers " for x in listareg: strlistareg+=x; print (strlistareg) valores= cf.execute_command(gdb=gdb, to_execute=strlistareg) print("===========VALORES==========") regs={} for x in valores: print(x) m = re.match(r".*R(\d+).*0x([0-9a-fA-F]+).*", x) if m: regs[m.group(1)]=m.group(2) print (str(m.group(0))+" "+str(m.group(1))) #Loop---- gdb.execute("nexti") linea= cf.execute_command(gdb=gdb, to_execute="x/1i $pc") valores= cf.execute_command(gdb=gdb, to_execute=strlistareg) regdst={} for x in valores: print(x) m = re.match(r".*R(\d+).*0x([0-9a-fA-F]+).*", x) if m: if (regs[m.group(1)]!=m.group(2)) regdst.add(m.group(1)) print (type(lista)) print(lista) def set_event(event): global trun,ocurrencias,t if (isinstance(event, gdb.BreakpointEvent)): t=time.clock() ocurrencias=ocurrencias+1 else: trun=(time.clock()-t) def main(): global ocurrencias,t,nosalir,trun was_hit = False ocurrencias=0 # Initialize GDB to run the appset pagination off gdb.execute("set confirm off") gdb.execute("set pagination off") gdb.execute("set target-async off") gdb.execute("set non-stop off") # Connecting to a exit handler event gdb.events.exited.connect(exit_handler) # Connecting to a stop signal event gdb.events.stop.connect(set_event) #gdb.execute("file ~/rodinia_3.1/cuda/lud/cuda/lud_cuda") #gdb.execute("set arg -s 10000") #gdb.execute("break lud_cuda") gdb.execute("file codes/mmElem/matrixMul") gdb.execute("set arg -wA=16384 -hA=16384 -hB=16384 -wB=16384") gdb.execute("set cuda break_on_launch application") gdb.execute('r') selectrd() nosalir=True while nosalir: gdb.execute("finish") gdb.execute("c") print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun)) f=open("tmpxxx_return_profiler.conf","w") f.write("Ocurrencias ="+str(ocurrencias)+"\n Tiempo "+str(trun)+"\n") f.close() main()