summaryrefslogtreecommitdiff
path: root/tools/perf/python
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-09-25 23:19:29 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-09-26 20:49:27 +0200
commit514ecdfd0073686e2a61681fe6f9e08870d9a89a (patch)
treeac8ec8a19a4350daf5d5bdd6efe406928920c883 /tools/perf/python
parentc4925cc8b8b1647b3cf9a9d8e84ac4c9f1e962c5 (diff)
downloadlinux-next-514ecdfd0073686e2a61681fe6f9e08870d9a89a.tar.gz
linux-next-514ecdfd0073686e2a61681fe6f9e08870d9a89a.zip
perf python: Update callchain stubs and session thread lookup
Update pyrf_session__find_thread() in util/python.c to accept an optional tid parameter (defaulting to pid) and return None instead of raising TypeError when a thread is not found in the session machines. Update perf.pyi to match: - Set session.find_thread() signature to (pid: int, tid: int = -1) -> Optional[thread]. - Update callchain_node.symbol and callchain_node.dso to str (the C getters return "[unknown]" fallback strings rather than None) and add __iter__() to callchain. Also update treport.py to handle Optional[thread] returned by session.find_thread(). Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/python')
-rw-r--r--tools/perf/python/perf.pyi7
-rwxr-xr-xtools/perf/python/treport.py2
2 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/python/perf.pyi b/tools/perf/python/perf.pyi
index c390e17708b1..92aad84ca542 100644
--- a/tools/perf/python/perf.pyi
+++ b/tools/perf/python/perf.pyi
@@ -332,13 +332,14 @@ class branch_stack:
class callchain_node:
"""Represents a frame in the callchain."""
ip: int
- symbol: Optional[str]
- dso: Optional[str]
+ symbol: str
+ dso: str
class callchain:
"""Sequence of callchain frames."""
def __len__(self) -> int: ...
def __getitem__(self, index: int) -> callchain_node: ...
+ def __iter__(self) -> Iterator[callchain_node]: ...
class stat_event(_sample_members):
"""Represents a stat event from perf."""
@@ -453,7 +454,7 @@ class session:
def process_events(self) -> None:
"""Process all events in the session."""
...
- def find_thread(self, pid: int) -> thread:
+ def find_thread(self, pid: int, tid: int = -1, /) -> Optional[thread]:
"""Returns the thread associated with a pid."""
...
diff --git a/tools/perf/python/treport.py b/tools/perf/python/treport.py
index 43542599a884..786b852f471c 100755
--- a/tools/perf/python/treport.py
+++ b/tools/perf/python/treport.py
@@ -92,7 +92,7 @@ class ProfileNode:
try:
assert session
thread = session.find_thread(sample.sample_tid)
- comm = thread.comm()
+ comm = (thread.comm() if thread else None) or f"unknown ({pid})"
except Exception:
comm = f"unknown ({pid})"