Sections
Timeline
View Tickets
New Ticket
Sub-Sections
Download
Unified Diff
Zip Archive
Metanav
Preferences
About Trac
Links
Slowchop Studios
Gerald Kaszuba
Advertisement

Changeset 11

Show
Ignore:
Timestamp:
10/02/07 03:40:45 (22 months ago)
Author:
gak
Message:

Added reset trace and dont ignore anything options

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pycallgraph.py

    r10 r11  
    2626 
    2727# statistical data 
    28 call_dict = {} 
    29 call_stack = ['__main__'] 
    30 func_count = {} 
    31 func_count_max = 0 
     28def reset_trace(): 
     29    global call_dict 
     30    call_dict = {} 
     31    global call_stack 
     32    call_stack = ['__main__'] 
     33    global func_count 
     34    func_count = {} 
     35    global func_count_max 
     36    func_count_max = 0 
     37 
     38reset_trace() 
    3239 
    3340# graphviz settings 
     
    4350    }, 
    4451} 
     52 
     53# settings for building dot files 
    4554settings = { 
    4655   'node_attributes': { 
     
    5867    'include_func': [], 
    5968    'include_specific': [], 
     69    'dont_exclude_anything': False, 
    6070} 
    6171 
     
    6373    pass 
    6474 
    65 def start_trace(): 
     75def start_trace(reset=True): 
     76    if reset: 
     77        reset_trace() 
    6678    sys.settrace(tracer) 
    6779 
     
    110122        func_name = code.co_name 
    111123        if func_name == '?': 
    112             func_name = 'nofunc' 
    113             dont_keep = True 
     124            func_name = '__main__' 
    114125        else: 
    115126            if settings['include_func']: 
     
    128139        # throw it all in dictonaires 
    129140        fr = call_stack[-1] 
    130         if not dont_keep: 
     141        if not dont_keep or settings['dont_exclude_anything']: 
    131142            if fr not in call_dict: 
    132143                call_dict[fr] = {}