diff options
author | Yabin Cui <yabinc@google.com> | 2017-04-13 13:44:15 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-04-13 13:44:15 -0700 |
commit | 5bcac01d4dbced62bbbd2f334eb662af43148f6e (patch) | |
tree | 3a74afeda7f1c1f59392082d87ebb31ed1ccb212 /simpleperf | |
parent | 248a0baefe84bc145f85b9425de4971a6f895a6c (diff) | |
download | extras-5bcac01d4dbced62bbbd2f334eb662af43148f6e.tar.gz |
simpleperf: fix pprof proto generator.
Bug: http://b/36988814
Test: run pprof_proto_generator.py and no function_id == 0.
Change-Id: I42bead12818e2d9396c4e52afc2dca84558d7731
Diffstat (limited to 'simpleperf')
-rw-r--r-- | simpleperf/scripts/pprof_proto_generator.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/simpleperf/scripts/pprof_proto_generator.py b/simpleperf/scripts/pprof_proto_generator.py index 5f8d143b..c877a167 100644 --- a/simpleperf/scripts/pprof_proto_generator.py +++ b/simpleperf/scripts/pprof_proto_generator.py @@ -379,11 +379,14 @@ class PprofProfileGenerator(object): def get_location_id(self, ip, symbol): mapping_id = self.get_mapping_id(symbol.mapping[0], symbol.dso_name) location = Location(mapping_id, ip, symbol.vaddr_in_file) - # Default line info only contains the function name - line = Line() - line.function_id = self.get_function_id(symbol.symbol_name, symbol.dso_name, - symbol.symbol_addr) - location.lines.append(line) + function_id = self.get_function_id(symbol.symbol_name, symbol.dso_name, + symbol.symbol_addr) + if function_id: + # Add Line only when it has a valid function id, see http://b/36988814. + # Default line info only contains the function name + line = Line() + line.function_id = function_id + location.lines.append(line) exist_location = self.location_map.get(location.key) if exist_location: @@ -462,10 +465,13 @@ class PprofProfileGenerator(object): source_id = 0 for source in sources: if source.file and source.function and source.line: + function_id = self.get_function_id(source.function, dso_name, 0) + if function_id == 0: + continue if source_id == 0: # Clear default line info location.lines = [] - location.lines.append(self.add_line(source, dso_name)) + location.lines.append(self.add_line(source, dso_name, function_id)) source_id += 1 for function in self.function_list: @@ -478,9 +484,8 @@ class PprofProfileGenerator(object): if source.line: function.start_line = source.line - def add_line(self, source, dso_name): + def add_line(self, source, dso_name, function_id): line = Line() - function_id = self.get_function_id(source.function, dso_name, 0) function = self.get_function(function_id) function.source_filename_id = self.get_string_id(source.file) line.function_id = function_id |