File: interp_debug.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (50 lines) | stat: -rw-r--r-- 1,490 bytes parent folder | download | duplicates (7)
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
from pypy.interpreter.gateway import unwrap_spec
from rpython.rlib import debug, jit
from rpython.rlib import rtimer

@jit.dont_look_inside
@unwrap_spec(category='text', timestamp=bool)
def debug_start(space, category, timestamp=False):
    res = debug.debug_start(category, timestamp=timestamp)
    if timestamp:
        return space.newint(res)
    return space.w_None

@jit.dont_look_inside
def debug_print(space, args_w):
    parts = [space.text_w(space.str(w_item)) for w_item in args_w]
    debug.debug_print(' '.join(parts))

@jit.dont_look_inside
@unwrap_spec(category='text', timestamp=bool)
def debug_stop(space, category, timestamp=False):
    res = debug.debug_stop(category, timestamp=timestamp)
    if timestamp:
        return space.newint(res)
    return space.w_None

@unwrap_spec(category='text')
def debug_print_once(space, category, args_w):
    debug_start(space, category)
    debug_print(space, args_w)
    debug_stop(space, category)


@jit.dont_look_inside
def debug_flush(space):
    debug.debug_flush()

def debug_read_timestamp(space):
    return space.newint(rtimer.read_timestamp())

def debug_get_timestamp_unit(space):
    unit = rtimer.get_timestamp_unit()
    if unit == rtimer.UNIT_TSC:
        unit_str = 'tsc'
    elif unit == rtimer.UNIT_NS:
        unit_str = 'ns'
    elif unit == rtimer.UNIT_QUERY_PERFORMANCE_COUNTER:
        unit_str = 'QueryPerformanceCounter'
    else:
        unit_str = 'UNKNOWN(%d)' % unit
    return space.newtext(unit_str)