Commit b86540d9 authored by German Leon's avatar German Leon
Browse files

Mas refinado, parece que version definitiva

parent 31d82b8c
......@@ -67,7 +67,7 @@ def profiler_caller(gdb_exec, kernels, benchmark_binary, benchmark_args,device,s
for i in range(0, cp.MAX_TIMES_TO_PROFILE):
start = time.time()
#os.system(profiler_cmd)
os.system(profiler_cmd)
end = time.time()
ret_profiler = cf.load_config_file("tmpxxx_return_profiler.conf")
acc_time_profiler+=float(ret_profiler.get('DEFAULT', 'Tiempo'))
......
import gdb
import time
import re
import sys
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 numreg (kernel):
try:
disassemble_array = cf.execute_command(gdb=gdb, to_execute="disassemble {}".format(kernel))
except:
disassemble_array = cf.execute_command(gdb=gdb, to_execute="disassemble")
listareg=set()
listaregdst=set()
listaregcond=set()
for i in range(0, len(disassemble_array) - 1):
line = disassemble_array[i]
m=re.match(r".*:\t(\S+) .*",line)
# print("ASSM_LINE:{}".format(l))
todacadena="ASSM_LINE:{}".format(line)
print(todacadena)
lista=re.findall(r"R(\d+)", line)
if (len(lista) > 0):
listareg.update(lista)
print (listareg)
listaregdst.add (lista[0])
print (listaregdst)
lista=re.findall(r" P(\d+)", line)
if (len(lista) > 0):
print (listaregcond)
listaregcond.update(lista)
# if m and m.group(1) != '0':
# Print ("Encontrado"
print ("Registros Visibles ({})".format(len(listareg)))
print (listareg)
print ("Registros destino ({})".format(len(listaregdst)))
print (listaregdst)
print ("Registros condicionales ({})".format(len(listaregcond)))
print (listaregcond)
return (len(listareg))
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.time()
print ("Tomo tiempo " + str (t))
ocurrencias=ocurrencias+1
else:
print ("Para tiempo " + str (time.time()))
trun=(time.time()-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(";",3)
print >>sys.stderr, (cadena[0]) #,"-",cadena[0],"-",cadena[1],"-", cadena[2],"#". cadena[3])
section =cadena[0]=="True"
onlycount=cadena[1]=="True"
#print ("B "+section+"ke "+kernel_end+" ....")
#print (cadena[2].split(";"))
for init_str in cadena[3].split(";"):
gdb.execute(init_str)
maxi=0.
gdb.execute("r")
if (onlycount):
ks=cadena[2].split(",",1)
print (ks)
maxi=max([ numreg(x) for x in ks])
print("Maximo.."+str (maxi))
else:
if (section):
gdb.execute("c")
else:
gdb.execute("finish")
f=open("tmpxxx_return_profiler.conf","w")
f.write("[DEFAULT] \nOcurrencias = "+str(ocurrencias)+"\nTiempo = "+str(trun)+"\n")
f.close()
sys.exit(maxi)
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment