diff options
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 |