summaryrefslogtreecommitdiff
path: root/tools/perf/python
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-09-25 23:19:35 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-09-26 20:49:27 +0200
commit7a481f6c712a1505f67b97add508bb9d393c9d22 (patch)
treee1cbee16020345f95d14ede4f727d656edb67ba6 /tools/perf/python
parent4b15226c14df50c8c9ca67e35295bf8c7ae71574 (diff)
perf python: Expose addr location, transaction, and context_switch
Expose destination address location components (addr_dso, addr_symbol, addr_sym_offset), branch/transaction metrics (branch_type, in_tx, flags, transaction), machine_pid, vcpu, sym_offset, and context_switch callbacks directly to the Python extension. Also include supporting fixes and infrastructure updates in util/python.c and perf.pyi: - Support fetching sym_offset on resolved sample symbols. - Populate sample machine_pid and vcpu from evlist__id2sid() when perf_guest is enabled, and resolve samples against the matching guest or host machine. - Expose next_prev_pid and next_prev_tid on switch_event only for PERF_RECORD_SWITCH_CPU_WIDE records (returning None otherwise). - Wire up tracing_data in pyrf_session__new() and update perf.pyi type stubs (including srccode() and insn() return types). 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.pyi23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/perf/python/perf.pyi b/tools/perf/python/perf.pyi
index 92aad84ca542..44c693761838 100644
--- a/tools/perf/python/perf.pyi
+++ b/tools/perf/python/perf.pyi
@@ -194,6 +194,8 @@ class _sample_members:
sample_time: int
sample_id: int
sample_stream_id: int
+ machine_pid: int
+ vcpu: int
sample_period: int
sample_cpu: int
@@ -218,10 +220,18 @@ class sample_event(_sample_members):
symbol: str
sym_start: int
sym_end: int
+ sym_offset: Optional[int]
+ addr_dso: Optional[str]
+ addr_symbol: Optional[str]
+ addr_sym_offset: Optional[int]
+ branch_type: int
+ in_tx: int
+ flags: int
+ transaction: int
brstack: Optional['branch_stack']
callchain: Optional['callchain']
- def srccode(self) -> str: ...
- def insn(self) -> str: ...
+ def srccode(self) -> Optional[tuple[Optional[str], int, Optional[str]]]: ...
+ def insn(self) -> Optional[bytes]: ...
def __getattr__(self, name: str) -> Any: ...
class mmap_event(_sample_members):
@@ -298,8 +308,9 @@ class read_event(_sample_members):
class switch_event(_sample_members):
"""Represents a SWITCH or SWITCH_CPU_WIDE record."""
type: int
- next_prev_pid: int
- next_prev_tid: int
+ misc: int
+ next_prev_pid: Optional[int]
+ next_prev_tid: Optional[int]
evsel: Optional['evsel']
class branch_entry:
@@ -334,6 +345,7 @@ class callchain_node:
ip: int
symbol: str
dso: str
+ sym_offset: Optional[int]
class callchain:
"""Sequence of callchain frames."""
@@ -441,7 +453,8 @@ class session:
self,
data: data,
sample: Optional[Callable[[sample_event], None]] = None,
- stat: Optional[Callable[[Any, Optional[str]], None]] = None
+ stat: Optional[Callable[[Any, Optional[str]], None]] = None,
+ context_switch: Optional[Callable[[switch_event], None]] = None,
) -> None:
"""Initialize a perf session.