我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用symbol.SymbolInformationForSet()。
def _Symbolize(asan_input): asan_libs = _FindASanLibraries() libraries = collections.defaultdict(list) asan_lines = [] for asan_log_line in [a.rstrip() for a in asan_input]: m = _ParseAsanLogLine(asan_log_line) if m: libraries[m['library']].append(m) asan_lines.append({'raw_log': asan_log_line, 'parsed': m}) all_symbols = collections.defaultdict(dict) for library, items in libraries.iteritems(): libname = _TranslateLibPath(library, asan_libs) lib_relative_addrs = set([i['rel_address'] for i in items]) # pylint: disable=no-member info_dict = symbol.SymbolInformationForSet(libname, lib_relative_addrs, True) if info_dict: all_symbols[library]['symbols'] = info_dict for asan_log_line in asan_lines: m = asan_log_line['parsed'] if not m: print asan_log_line['raw_log'] continue if (m['library'] in all_symbols and m['rel_address'] in all_symbols[m['library']]['symbols']): s = all_symbols[m['library']]['symbols'][m['rel_address']][0] print '%s%s %s %s' % (m['prefix'], m['pos'], s[0], s[1]) else: print asan_log_line['raw_log']
def _Symbolize(asan_input): asan_libs = _FindASanLibraries() libraries = collections.defaultdict(list) asan_lines = [] for asan_log_line in [a.rstrip() for a in asan_input]: m = _ParseAsanLogLine(asan_log_line) if m: libraries[m['library']].append(m) asan_lines.append({'raw_log': asan_log_line, 'parsed': m}) all_symbols = collections.defaultdict(dict) for library, items in libraries.iteritems(): libname = _TranslateLibPath(library, asan_libs) lib_relative_addrs = set([i['rel_address'] for i in items]) info_dict = symbol.SymbolInformationForSet(libname, lib_relative_addrs, True) if info_dict: all_symbols[library]['symbols'] = info_dict for asan_log_line in asan_lines: m = asan_log_line['parsed'] if not m: print asan_log_line['raw_log'] continue if (m['library'] in all_symbols and m['rel_address'] in all_symbols[m['library']]['symbols']): s = all_symbols[m['library']]['symbols'][m['rel_address']][0] print '%s%s %s %s' % (m['prefix'], m['pos'], s[0], s[1]) else: print asan_log_line['raw_log']