Commit Graph
7 Commits
Author SHA1 Message Date
Dean 6e747a2a3b Merge pull request #11427 from StoneDC/fix/symbolizer-module-read-errors
fix(tools): keep unreadable sampler modules unsymbolized
2026-10-27 18:37:58 +13:00
Dean 1a7ac56d27 Merge pull request #11355 from hakarrr/fix/preserve-sampler-captures
fix(tools): preserve raw captures when symbolizing samples
2026-10-27 18:34:10 +13:00
StoneDC 928d17c715 fix(tools): keep unreadable sampler modules unsymbolized 2026-10-26 23:59:42 +08:00
generaltony007andgeneraltony007 1fba662c84 fix(tools): preserve raw captures when symbolizing samples
Reject --out aliases of either input capture before loading or writing so symbolized output cannot destroy raw RVA and module identity records.

Co-authored-by: generaltony007 <[email protected]>
2026-10-26 13:02:24 +05:30
B-Howell 0c529db4bc fix(tools): verify sampler windows against the later capture
Keep module identity evidence local to the later snapshot rather than inheriting older records through --since. Cover raw address and collapsed stack inputs, explicit unverified operation, and a changed build identity.

AI-assisted: yes (Codex).
2026-10-25 16:10:10 -04:00
JJenkxandClaude Opus 5.5 cdc21a9897 fix(tools): bound symbol lookups to their section, keep inclusive counts and refuse unrecorded modules
Review of #9572 found three gaps:

- PeModule.name() checked that an RVA was in some code section, then
  bisected one list of every symbol, so an address in a later code
  section before that section's first symbol took the last symbol of an
  earlier section. Each code section now keeps its own sorted list.
- Address files keep both counters ('module offset self inclusive'):
  the inclusive count is kept and subtracted by --since, and the summary
  lists functions by inclusive samples as well, summed over each
  function's addresses (an upper bound when a function is on one stack
  more than once). The total comes from the '# N samples' line or from
  the 'thread <id> samples <n>' headings of APS5_SAMPLE_THREADS, which
  the loader previously misread as a stack line; --thread keeps one
  thread.
- The address writers of both samplers wrote no '# module' records, so
  those files skipped the size and timestamp check. Both now write them
  (through the helper the collapsed-stack writer uses), and the tool
  leaves a module unsymbolized when the samples have no record for it,
  unless --unverified is given.

Five new cases cover a second code section, inclusive totals, --since
on an address file, thread headings with --thread, and the missing
record with and without --unverified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 01:49:21 -04:00
JJenkxandClaude Opus 5.5 59693ae54c feat(tools): symbolize the Windows samplers' stacks
The Windows samplers (APS5_SAMPLE_WORKER, APS5_SAMPLE_COMMITTER and
APS5_SAMPLE_THREADS) write every frame as module+0xRVA, and BUILD.md left
naming them to the reader ("for example with nm on the .prx"). Doing that
by hand means finding each module's image base, choosing between COFF
symbols and the export table, and keeping the files cumulative totals in
mind.

tools/symbolize_samples.py reads a collapsed-stack file or the address
file, opens each module it finds in --libs as a PE32+ image, and names
every frame module!function:

- From the COFF symbol table that the MinGW-built .prx and .dll keep:
  external and static symbols in code sections, at the section's RVA
  plus the symbol value. Addresses outside a code section, or before the
  first symbol, stay module+0xRVA.
- From the export table, prefixed with "~", for a module without
  symbols, such as the runtime DLLs.
- A module whose SizeOfImage or TimeDateStamp differs from the sampler's
  "# module" line is left unsymbolized, with a warning: its addresses
  would name the wrong functions.

--since subtracts an earlier copy of the same file, which keeps only the
samples taken between the two copies (the files hold totals since
start-up). --out writes the named stacks for speedscope or flamegraph.pl.
--demangle uses c++filt when it is on PATH. It needs no binutils
otherwise.

test_symbolize_samples (registered with CTest) builds small PE32+ images
with COFF symbols and with an export table, and covers short, string-table
and static names, the ignored section and data symbols, addresses outside
code, the export fallback, the size and timestamp check, --since with
--out, the address-file format and rejected lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 01:49:21 -04:00