| 694 | |
| 695 | |
| 696 | class LibraryRepo(object): |
| 697 | def __init__(self): |
| 698 | self.infos = [] |
| 699 | self.names = set() |
| 700 | self.ticks = {} |
| 701 | |
| 702 | |
| 703 | def HasDynamicSymbols(self, filename): |
| 704 | if filename.endswith(".ko"): return False |
| 705 | process = subprocess.Popen( |
| 706 | "%s -h %s" % (OBJDUMP_BIN, filename), |
| 707 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 708 | pipe = process.stdout |
| 709 | try: |
| 710 | for line in pipe: |
| 711 | match = OBJDUMP_SECTION_HEADER_RE.match(line.decode()) |
| 712 | if match and match.group(1) == 'dynsym': |
| 713 | return True |
| 714 | finally: |
| 715 | pipe.close() |
| 716 | assert process.wait() == 0, "Failed to objdump -h %s" % filename |
| 717 | return False |
| 718 | |
| 719 | |
| 720 | def Load(self, mmap_info, code_map, options): |
| 721 | # Skip kernel mmaps when requested using the fact that their tid |
| 722 | # is 0. |
| 723 | if mmap_info.tid == 0 and not options.kernel: |
| 724 | return True |
| 725 | if OBJDUMP_SKIP_RE.match(mmap_info.filename): |
| 726 | return True |
| 727 | if PERF_KERNEL_ALLSYMS_RE.match(mmap_info.filename): |
| 728 | return self._LoadKernelSymbols(code_map) |
| 729 | self.infos.append(mmap_info) |
| 730 | mmap_info.ticks = 0 |
| 731 | mmap_info.unique_name = self._UniqueMmapName(mmap_info) |
| 732 | if not os.path.exists(mmap_info.filename): |
| 733 | return True |
| 734 | # Request section headers (-h), symbols (-t), and dynamic symbols |
| 735 | # (-T) from objdump. |
| 736 | # Unfortunately, section headers span two lines, so we have to |
| 737 | # keep the just seen section name (from the first line in each |
| 738 | # section header) in the after_section variable. |
| 739 | if self.HasDynamicSymbols(mmap_info.filename): |
| 740 | dynamic_symbols = "-T" |
| 741 | else: |
| 742 | dynamic_symbols = "" |
| 743 | process = subprocess.Popen( |
| 744 | "%s -h -t %s -C %s" % (OBJDUMP_BIN, dynamic_symbols, mmap_info.filename), |
| 745 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 746 | pipe = process.stdout |
| 747 | after_section = None |
| 748 | code_sections = set() |
| 749 | reloc_sections = set() |
| 750 | dynamic = False |
| 751 | try: |
| 752 | for line in pipe: |
| 753 | line = line.decode() |
no outgoing calls
no test coverage detected
searching dependent graphs…