Debian Codegraph @

pypy/module/__pypy__/interp_debug.py

raw symbols SCIP
1 from pypy.interpreter.gateway import unwrap_spec
2 from rpython.rlib import debug, jit
3 from rpython.rlib import rtimer
4
5 @jit.dont_look_inside
6 @unwrap_spec(category='text', timestamp=bool)
7 def debug_start(space, category, timestamp=False):
8 res = debug.debug_start(category, timestamp=timestamp)
9 if timestamp:
10 return space.newint(res)
11 return space.w_None
12
13 @jit.dont_look_inside
14 def debug_print(space, args_w):
15 parts = [space.text_w(space.str(w_item)) for w_item in args_w]
16 debug.debug_print(' '.join(parts))
17
18 @jit.dont_look_inside
19 @unwrap_spec(category='text', timestamp=bool)
20 def debug_stop(space, category, timestamp=False):
21 res = debug.debug_stop(category, timestamp=timestamp)
22 if timestamp:
23 return space.newint(res)
24 return space.w_None
25
26 @unwrap_spec(category='text')
27 def debug_print_once(space, category, args_w):
28 debug_start(space, category)
29 debug_print(space, args_w)
30 debug_stop(space, category)
31
32
33 @jit.dont_look_inside
34 def debug_flush(space):
35 debug.debug_flush()
36
37 def debug_read_timestamp(space):
38 return space.newint(rtimer.read_timestamp())
39
40 def debug_get_timestamp_unit(space):
41 unit = rtimer.get_timestamp_unit()
42 if unit == rtimer.UNIT_TSC:
43 unit_str = 'tsc'
44 elif unit == rtimer.UNIT_NS:
45 unit_str = 'ns'
46 elif unit == rtimer.UNIT_QUERY_PERFORMANCE_COUNTER:
47 unit_str = 'QueryPerformanceCounter'
48 else:
49 unit_str = 'UNKNOWN(%d)' % unit
50 return space.newtext(unit_str)