prueba.py 1.5 KB
Newer Older
German Leon's avatar
German Leon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
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
      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('r')
    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()