import gdb import time 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 set_event(event): global trun,ocurrencias,t,primera print ("Es mi primera vez"+ str(primera)+" "+str(ocurrencias)) if (isinstance(event, gdb.BreakpointEvent)): if (primera): t=time.clock() ocurrencias=ocurrencias+1 else: trun=(time.clock()-t) primera=not primera else: trun=(time.clock()-t) """ Main function """ def main(): global ocurrencias,t,nosalir,trun,primera primera=True ; ocurrencias=0; # Initialize GDB to run the app 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_init_strings = str(os.environ["CAROL_FI_INFO"]) gdb_init_strings = arg0 cadena=gdb_init_strings.split(";",2) #print (cadena,"-",cadena[0],'-',cadena[1],'-', cadena[2]) section =cadena[0]=="True" kernel_end=cadena[1] #print ("B "+section+"ke "+kernel_end+" ....") #print (cadena[2].split(";")) for init_str in cadena[2].split(";"): gdb.execute(init_str) if (section): gdb.execute ("break "+kernel_end) gdb.execute("r") #nosalir=True #while nosalir: if (section): #print ("Point 1") gdb.execute("c") else: gdb.execute("finish") #print ("Punto 2") #print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun)+ "\n") gdb.execute("c") #print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun)) f=open("tmpxxx_return_profiler.conf","w") f.write("[DEFAULT] \nOcurrencias = "+str(ocurrencias)+"\nTiempo = "+str(trun)+"\n") f.close() #print ("End write file \n") #sys.stdout.flush() main()