Skip to content

fix(jitdump): support MacOS u64 tid fields#1

Open
not-matthias wants to merge 3 commits into
mainfrom
cod-2645-investigate-python_perf_jit_support-not-working-on-macos
Open

fix(jitdump): support MacOS u64 tid fields#1
not-matthias wants to merge 3 commits into
mainfrom
cod-2645-investigate-python_perf_jit_support-not-working-on-macos

Conversation

@not-matthias

Copy link
Copy Markdown

No description provided.

Add end-to-end parse tests over real cpython perf jitdump captures: a
Linux x86_64 dump in the standard layout (u32 tid) and a macOS arm64 dump
in the wider layout (u64 tid + alignment padding). Each must yield 195
CODE_LOAD + 195 CODE_UNWINDING_INFO records, exercising the per-record
layout detection.
CPython on macOS declares the jitdump thread_id as uint64_t (filled via
pthread_threadid_np) instead of the perf spec's uint32_t, adding 8 bytes
(wider field + alignment padding) that shift the name and code bytes in every
CODE_LOAD/CODE_MOVE record. The u32-only parser misread code_size as the code
address and failed to parse these files at all.

Widen tid to u64 and detect the layout per record from the body length: try
the standard layout first, fall back to the wider macOS layout when the field
offsets are not self-consistent with the record size.
try_parse now returns Result<Option<Self>, io::Error>: Ok(None) signals only a
layout mismatch, while genuine read errors (e.g. UnexpectedEof on a truncated
record) propagate. The narrower standard layout's read errors surface as
truncation; the wider layout's are treated as "not this layout". Adds a
regression test. Addresses PR #3 review feedback.
@not-matthias not-matthias force-pushed the cod-2645-investigate-python_perf_jit_support-not-working-on-macos branch from ebb5745 to effe486 Compare June 1, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant