OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 KERNEL_ALLSYMS_LINE_RE = re.compile( | 704 KERNEL_ALLSYMS_LINE_RE = re.compile( |
705 r"^([a-f0-9]+)\s(?:t|T)\s(\S+)$") | 705 r"^([a-f0-9]+)\s(?:t|T)\s(\S+)$") |
706 | 706 |
707 | 707 |
708 class LibraryRepo(object): | 708 class LibraryRepo(object): |
709 def __init__(self): | 709 def __init__(self): |
710 self.infos = [] | 710 self.infos = [] |
711 self.names = set() | 711 self.names = set() |
712 self.ticks = {} | 712 self.ticks = {} |
713 | 713 |
| 714 |
| 715 def HasDynamicSymbols(self, filename): |
| 716 if filename.endswith(".ko"): return False |
| 717 process = subprocess.Popen( |
| 718 "%s -h %s" % (OBJDUMP_BIN, filename), |
| 719 shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 720 pipe = process.stdout |
| 721 try: |
| 722 for line in pipe: |
| 723 match = OBJDUMP_SECTION_HEADER_RE.match(line) |
| 724 if match and match.group(1) == 'dynsym': return True |
| 725 finally: |
| 726 pipe.close() |
| 727 assert process.wait() == 0, "Failed to objdump -h %s" % filename |
| 728 return False |
| 729 |
| 730 |
714 def Load(self, mmap_info, code_map, options): | 731 def Load(self, mmap_info, code_map, options): |
715 # Skip kernel mmaps when requested using the fact that their tid | 732 # Skip kernel mmaps when requested using the fact that their tid |
716 # is 0. | 733 # is 0. |
717 if mmap_info.tid == 0 and not options.kernel: | 734 if mmap_info.tid == 0 and not options.kernel: |
718 return True | 735 return True |
719 if OBJDUMP_SKIP_RE.match(mmap_info.filename): | 736 if OBJDUMP_SKIP_RE.match(mmap_info.filename): |
720 return True | 737 return True |
721 if PERF_KERNEL_ALLSYMS_RE.match(mmap_info.filename): | 738 if PERF_KERNEL_ALLSYMS_RE.match(mmap_info.filename): |
722 return self._LoadKernelSymbols(code_map) | 739 return self._LoadKernelSymbols(code_map) |
723 self.infos.append(mmap_info) | 740 self.infos.append(mmap_info) |
724 mmap_info.ticks = 0 | 741 mmap_info.ticks = 0 |
725 mmap_info.unique_name = self._UniqueMmapName(mmap_info) | 742 mmap_info.unique_name = self._UniqueMmapName(mmap_info) |
726 if not os.path.exists(mmap_info.filename): | 743 if not os.path.exists(mmap_info.filename): |
727 return True | 744 return True |
728 # Request section headers (-h), symbols (-t), and dynamic symbols | 745 # Request section headers (-h), symbols (-t), and dynamic symbols |
729 # (-T) from objdump. | 746 # (-T) from objdump. |
730 # Unfortunately, section headers span two lines, so we have to | 747 # Unfortunately, section headers span two lines, so we have to |
731 # keep the just seen section name (from the first line in each | 748 # keep the just seen section name (from the first line in each |
732 # section header) in the after_section variable. | 749 # section header) in the after_section variable. |
733 if mmap_info.filename.endswith(".ko"): | 750 if self.HasDynamicSymbols(mmap_info.filename): |
| 751 dynamic_symbols = "-T" |
| 752 else: |
734 dynamic_symbols = "" | 753 dynamic_symbols = "" |
735 else: | |
736 dynamic_symbols = "-T" | |
737 process = subprocess.Popen( | 754 process = subprocess.Popen( |
738 "%s -h -t %s -C %s" % (OBJDUMP_BIN, dynamic_symbols, mmap_info.filename), | 755 "%s -h -t %s -C %s" % (OBJDUMP_BIN, dynamic_symbols, mmap_info.filename), |
739 shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 756 shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
740 pipe = process.stdout | 757 pipe = process.stdout |
741 after_section = None | 758 after_section = None |
742 code_sections = set() | 759 code_sections = set() |
743 reloc_sections = set() | 760 reloc_sections = set() |
744 dynamic = False | 761 dynamic = False |
745 try: | 762 try: |
746 for line in pipe: | 763 for line in pipe: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") | 1020 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") |
1004 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") | 1021 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") |
1005 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") | 1022 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") |
1006 print "%10d total symbols" % len([c for c in code_map.AllCode()]) | 1023 print "%10d total symbols" % len([c for c in code_map.AllCode()]) |
1007 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) | 1024 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) |
1008 print "%9.2fs library processing time" % mmap_time | 1025 print "%9.2fs library processing time" % mmap_time |
1009 print "%9.2fs tick processing time" % sample_time | 1026 print "%9.2fs tick processing time" % sample_time |
1010 | 1027 |
1011 log_reader.Dispose() | 1028 log_reader.Dispose() |
1012 trace_reader.Dispose() | 1029 trace_reader.Dispose() |
OLD | NEW |