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 | |
ulan
2015/03/16 08:58:05
Let's make the result explicit instead of returnin
| |
728 | |
729 | |
714 def Load(self, mmap_info, code_map, options): | 730 def Load(self, mmap_info, code_map, options): |
715 # Skip kernel mmaps when requested using the fact that their tid | 731 # Skip kernel mmaps when requested using the fact that their tid |
716 # is 0. | 732 # is 0. |
717 if mmap_info.tid == 0 and not options.kernel: | 733 if mmap_info.tid == 0 and not options.kernel: |
718 return True | 734 return True |
719 if OBJDUMP_SKIP_RE.match(mmap_info.filename): | 735 if OBJDUMP_SKIP_RE.match(mmap_info.filename): |
720 return True | 736 return True |
721 if PERF_KERNEL_ALLSYMS_RE.match(mmap_info.filename): | 737 if PERF_KERNEL_ALLSYMS_RE.match(mmap_info.filename): |
722 return self._LoadKernelSymbols(code_map) | 738 return self._LoadKernelSymbols(code_map) |
723 self.infos.append(mmap_info) | 739 self.infos.append(mmap_info) |
724 mmap_info.ticks = 0 | 740 mmap_info.ticks = 0 |
725 mmap_info.unique_name = self._UniqueMmapName(mmap_info) | 741 mmap_info.unique_name = self._UniqueMmapName(mmap_info) |
726 if not os.path.exists(mmap_info.filename): | 742 if not os.path.exists(mmap_info.filename): |
727 return True | 743 return True |
728 # Request section headers (-h), symbols (-t), and dynamic symbols | 744 # Request section headers (-h), symbols (-t), and dynamic symbols |
729 # (-T) from objdump. | 745 # (-T) from objdump. |
730 # Unfortunately, section headers span two lines, so we have to | 746 # Unfortunately, section headers span two lines, so we have to |
731 # keep the just seen section name (from the first line in each | 747 # keep the just seen section name (from the first line in each |
732 # section header) in the after_section variable. | 748 # section header) in the after_section variable. |
733 if mmap_info.filename.endswith(".ko"): | 749 if self.HasDynamicSymbols(mmap_info.filename): |
750 dynamic_symbols = "-T" | |
751 else: | |
734 dynamic_symbols = "" | 752 dynamic_symbols = "" |
735 else: | |
736 dynamic_symbols = "-T" | |
737 process = subprocess.Popen( | 753 process = subprocess.Popen( |
738 "%s -h -t %s -C %s" % (OBJDUMP_BIN, dynamic_symbols, mmap_info.filename), | 754 "%s -h -t %s -C %s" % (OBJDUMP_BIN, dynamic_symbols, mmap_info.filename), |
739 shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 755 shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
740 pipe = process.stdout | 756 pipe = process.stdout |
741 after_section = None | 757 after_section = None |
742 code_sections = set() | 758 code_sections = set() |
743 reloc_sections = set() | 759 reloc_sections = set() |
744 dynamic = False | 760 dynamic = False |
745 try: | 761 try: |
746 for line in pipe: | 762 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") | 1019 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") |
1004 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") | 1020 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") |
1005 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") | 1021 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") |
1006 print "%10d total symbols" % len([c for c in code_map.AllCode()]) | 1022 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()]) | 1023 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) |
1008 print "%9.2fs library processing time" % mmap_time | 1024 print "%9.2fs library processing time" % mmap_time |
1009 print "%9.2fs tick processing time" % sample_time | 1025 print "%9.2fs tick processing time" % sample_time |
1010 | 1026 |
1011 log_reader.Dispose() | 1027 log_reader.Dispose() |
1012 trace_reader.Dispose() | 1028 trace_reader.Dispose() |
OLD | NEW |