Esempio n. 1
0
def print_module_trace():
    cursor_inf = get_cur_cursor_inf()
    # get cur module name
    cur_module_name = ''
    cur_module_inf = None
    cur_line_inf = FileInfLib.get_file_line_inf(cursor_inf['line_num'],
                                                cursor_inf['file_path'])
    if cur_line_inf:
        cur_module_inf = cur_line_inf['module_inf']
    if not cur_module_inf:
        PrintReport('Note: current cursor not in valid module, do-nothing !')
        return
    cur_module_name = cur_module_inf['module_name']
    # recursion get all trace
    full_traces = []
    FileInfLib.recursion_get_module_trace(cur_module_name, [], full_traces)
    print_strs = []
    i_offset = 0  # used to control multi same trace case
    for i, traces in enumerate(full_traces):
        c_trace_strs = [traces[-1]['cur_module_name']]
        for t in traces[::-1]:
            c_str = '%s(%s)' % (t['instance_name'], t['submodule_name'])
            if c_str not in c_trace_strs:
                c_trace_strs.append(c_str)
            else:
                i_offset -= 1
        print_strs.append('%d : %s' %
                          (i + i_offset, ' -> '.join(c_trace_strs)))
    mounted_line_list = MountPrintLines(print_strs,
                                        label='Module Trace')['line_list']
    mounted_line_list.append('')
    mounted_line_list.append('')
    PrintReport(mounted_line_list, MountPrint=True)
    # edit_vim_buffer_and_file_link(G['Report_Inf']['Report_Path'], mounted_line_list)
    return
Esempio n. 2
0
def print_module_trace(to_module, from_module = None):
    full_traces = []
    FileInfLib.recursion_get_module_trace(to_module, [], full_traces)
    print_strs = []
    i_offset = 0 # used to control multi same trace case
    for i, traces in enumerate(full_traces):
        c_trace_strs = [ traces[-1]['cur_module_name'] ]
        for t in traces[::-1]:
            c_str = '%s(%s)'%(t['instance_name'], t['submodule_name'])
            if c_str not in c_trace_strs:
                c_trace_strs.append(c_str)
            else:
                i_offset -= 1
        print_strs.append( '%d : %s'%(i + i_offset, ' -> '.join(c_trace_strs) ) )
    MountPrintLines(print_strs, label = 'Module Trace', Print = True)