Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44914e0

Browse filesBrowse files
art049jbower-fb
authored andcommitted
pythongh-103650: Fix perf maps address format (python#103651)
1 parent 3145c0f commit 44914e0
Copy full SHA for 44914e0

File tree

Expand file treeCollapse file tree

3 files changed

+11
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-4
lines changed

‎Lib/test/test_perf_profiler.py

Copy file name to clipboardExpand all lines: Lib/test/test_perf_profiler.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import string
23
import subprocess
34
import sys
45
import sysconfig
@@ -70,9 +71,14 @@ def baz():
7071
perf_file = pathlib.Path(f"/tmp/perf-{process.pid}.map")
7172
self.assertTrue(perf_file.exists())
7273
perf_file_contents = perf_file.read_text()
73-
self.assertIn(f"py::foo:{script}", perf_file_contents)
74-
self.assertIn(f"py::bar:{script}", perf_file_contents)
75-
self.assertIn(f"py::baz:{script}", perf_file_contents)
74+
perf_lines = perf_file_contents.splitlines();
75+
expected_symbols = [f"py::foo:{script}", f"py::bar:{script}", f"py::baz:{script}"]
76+
for expected_symbol in expected_symbols:
77+
perf_line = next((line for line in perf_lines if expected_symbol in line), None)
78+
self.assertIsNotNone(perf_line, f"Could not find {expected_symbol} in perf file")
79+
perf_addr = perf_line.split(" ")[0]
80+
self.assertFalse(perf_addr.startswith("0x"), "Address should not be prefixed with 0x")
81+
self.assertTrue(set(perf_addr).issubset(string.hexdigits), "Address should contain only hex characters")
7682

7783
def test_trampoline_works_with_forks(self):
7884
code = """if 1:
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change the perf map format to remove the '0x' prefix from the addresses

‎Python/perf_trampoline.c

Copy file name to clipboardExpand all lines: Python/perf_trampoline.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ perf_map_write_entry(void *state, const void *code_addr,
253253
NULL);
254254
return;
255255
}
256-
fprintf(method_file, "%p %x py::%s:%s\n", code_addr, code_size, entry,
256+
fprintf(method_file, "%" PRIxPTR " %x py::%s:%s\n", (uintptr_t) code_addr, code_size, entry,
257257
filename);
258258
fflush(method_file);
259259
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.