diff options
author | Yabin Cui <yabinc@google.com> | 2017-11-10 15:15:26 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-11-10 15:20:54 -0800 |
commit | ce234a15db1a2cf41a3e80a0a7b39cbe9a66a54f (patch) | |
tree | 942c6f181983b99dd28e9e8bc50eb39014c7f815 | |
parent | cf17f8b24da1eef6b5e85346cdf0d10d796cb2d4 (diff) | |
download | extras-ce234a15db1a2cf41a3e80a0a7b39cbe9a66a54f.tar.gz |
simpleperf: show <> correctly in html report.
Html regards <> as tags, so it can't show source code and disassembly
with <> correctly. Fix this by replacing <> with '>' and '<'.
Also increase the percentage rectangle in FlamegraphView.
Bug: http://b/69128442
Test: run report_html.py on a perf.data having samples of a template function.
Change-Id: Ibbcfaac0cfaf56f10787ef6eea135f6ae781bd5a
-rw-r--r-- | simpleperf/scripts/report_html.js | 6 | ||||
-rw-r--r-- | simpleperf/scripts/report_html.py | 19 |
2 files changed, 15 insertions, 10 deletions
diff --git a/simpleperf/scripts/report_html.js b/simpleperf/scripts/report_html.js index 5f6b96bf..5e86c162 100644 --- a/simpleperf/scripts/report_html.js +++ b/simpleperf/scripts/report_html.js @@ -936,10 +936,10 @@ class FlameGraphView { _renderPercentNode() { this.svg.append(`<rect style="stroke:rgb(0,0,0);" rx="10" ry="10" \ - x="934" y="10" width="100" height="30" \ + x="934" y="10" width="150" height="30" \ fill="rgb(255,255,255)"/> \ <text id="percent_text_${this.id}" text-anchor="end" \ - x="1024" y="30">100.00%</text>`); + x="1074" y="30"></text>`); } _adjustTextSizeForNode(g) { @@ -1280,7 +1280,7 @@ class DisassemblyView { totalValue = sampleWeightFunction(line.subtreeEventCount); selfValue = sampleWeightFunction(line.eventCount); } - rows.push([totalValue, selfValue, line.code]); + rows.push([totalValue, selfValue, code]); } let data = new google.visualization.DataTable(); data.addColumn('string', 'Total'); diff --git a/simpleperf/scripts/report_html.py b/simpleperf/scripts/report_html.py index 52c7459b..01985f43 100644 --- a/simpleperf/scripts/report_html.py +++ b/simpleperf/scripts/report_html.py @@ -59,6 +59,8 @@ class HtmlWriter(object): self.add(f.read()) return self +def modify_text_for_html(text): + return text.replace('>', '>').replace('<', '<') class EventScope(object): @@ -745,11 +747,8 @@ class RecordData(object): thread_names[thread.tid] = thread.name return thread_names - def _modify_name_for_html(self, name): - return name.replace('>', '>').replace('<', '<') - def _gen_lib_list(self): - return [self._modify_name_for_html(x) for x in self.libs.lib_id_to_name] + return [modify_text_for_html(x) for x in self.libs.lib_id_to_name] def _gen_function_map(self): func_map = {} @@ -757,11 +756,14 @@ class RecordData(object): function = self.functions.id_to_func[func_id] func_data = {} func_data['l'] = function.lib_id - func_data['f'] = self._modify_name_for_html(function.func_name) + func_data['f'] = modify_text_for_html(function.func_name) if function.source_info: func_data['s'] = function.source_info if function.disassembly: - func_data['d'] = function.disassembly + disassembly_list = [] + for code, addr in function.disassembly: + disassembly_list.append([modify_text_for_html(code), addr]) + func_data['d'] = disassembly_list func_map[func_id] = func_data return func_map @@ -780,7 +782,10 @@ class RecordData(object): file_data['code'] = {} else: file_data['path'] = source_file.real_path - file_data['code'] = source_file.line_to_code + code_map = {} + for line in source_file.line_to_code: + code_map[line] = modify_text_for_html(source_file.line_to_code[line]) + file_data['code'] = code_map file_list.append(file_data) return file_list |