Skip to content

starboard: Modularize and unify symbolizer tools - #12585

Merged
jellefoks merged 5 commits into
youtube:mainfrom
jellefoks:feature/modular-unified-symbolizer
Sep 30, 2026
Merged

jellefoks merged 5 commits into
youtube:mainfrom
jellefoks:feature/modular-unified-symbolizer

Conversation

@jellefoks

@jellefoks jellefoks commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

starboard: Modularize and unify symbolizer tools

Refactor the symbolization toolset by decomposing logic into a high-
performance modular package. This introduces a centralized runner for
llvm-symbolizer with persistent subprocesses and caching, a registry
for diverse log formats, and dynamic address detection.

Convert asan_symbolize.py into a thin wrapper to maintain backward
compatibility while leveraging the new core. This architecture
improves maintainability and provides a unified interface for parsing
Android logcats, Cobalt stack dumps, and GDB outputs.

Bug: 524687034
Bug: 560199756
TAG=agy
CONV=8b5d7c17-137f-4cec-9795-2e00ef8ddffc

@github-actions

This comment was marked as resolved.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ✅ PASS All checks passed
CI / android ✅ PASS Passed
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ✅ PASS Passed
gemini-code-assist[bot]

This comment was marked as resolved.

@jellefoks

Copy link
Copy Markdown
Member Author

Overview

Unifies Cobalt's symbolization tools by decomposing starboard/tools/symbolize/ into a high-performance, modular package and converting tools/valgrind/asan/asan_symbolize.py into a thin backward-compatible wrapper.

Key Changes

  • Modular Package Architecture (starboard/tools/symbolize/):
    • runner.py: Implements SymbolizerRunner managing persistent llvm-symbolizer subprocesses with single-process multi-binary dispatch ("<binary>" <offset>), LRU caching, inlined frame parsing, and pipe deadlock prevention (stderr=subprocess.DEVNULL).
    • formats.py: Implements FormatRegistry and FormatHandler classes for ASan (Mode 1 & 2), Android logcat/tombstones, Cobalt stack dumps, GDB, and raw hex addresses with prefix and indentation preservation and inlined frame expansion.
    • detector.py: Implements StreamingSessionTracker dynamically extracting Load start=0x... markers across multi-session logs and providing three-tier address mode resolution.
    • json_processor.py: Decoupled test_summary.json processor with fast $O(1)$ signature pre-filtering.
    • symbolize.py: High-level streaming coordinator and CLI entry point.
  • Backward Compatibility:
    • tools/valgrind/asan/asan_symbolize.py converted to a thin wrapper delegating to starboard.tools.symbolize while preserving all existing CLI flags (--test-summary-json-file, --extra-binary, --executable-path, --sysroot, strip_path_prefix), stream piping, and in-place JSON rewrite semantics.
    • starboard/tools/symbolize/symbolize.py retains exact -f, -l, and positional base_address CLI arguments while adding additive non-breaking options.
  • Testing & CI:
    • Expanded starboard/tools/symbolize/symbolize_test.py to 39 unit, integration, and performance benchmark tests (processes 1,000+ frames in ~0.03s, well below the 2.0s limit).
    • Added baseline unit tests in tools/valgrind/asan/asan_symbolize_test.py (17 tests).
    • Wired asan_symbolize_test.py into .github/actions/symbolize_test/action.yaml.
  • Documentation:
    • Added comprehensive documentation in starboard/tools/symbolize/README.md.
@jellefoks
jellefoks force-pushed the feature/modular-unified-symbolizer branch from f1798ef to a860cfd Compare September 11, 2026 18:20
@jellefoks jellefoks changed the title tools: Implement modular unified symbolizer and wrap asan_symbolize.py Sep 11, 2026
@jellefoks
jellefoks force-pushed the feature/modular-unified-symbolizer branch from 93f73b9 to a4cbf0a Compare September 11, 2026 23:38
@jellefoks
jellefoks force-pushed the feature/modular-unified-symbolizer branch from a4cbf0a to b8edb5e Compare September 14, 2026 16:21
@jellefoks
jellefoks force-pushed the feature/modular-unified-symbolizer branch from b8edb5e to efc59e3 Compare September 15, 2026 01:18
@jellefoks
jellefoks force-pushed the feature/modular-unified-symbolizer branch from 8356805 to f314169 Compare September 17, 2026 02:54
- Decompose starboard/tools/symbolize/ into a modular package:
  - runner.py: Persistent SymbolizerRunner managing llvm-symbolizer with
    multi-binary dispatch, deadlock prevention (stderr=DEVNULL), and LRU cache.
  - formats.py: FormatHandler registry supporting ASan, Android tombstone,
    Cobalt stack dumps, GDB, and raw addresses with prefix and inlines preservation.
  - detector.py: StreamingSessionTracker for dynamic Load start= tracking
    and three-tier address mode resolution.
  - json_processor.py: Decoupled test runner JSON summary processor with
    fast O(1) stack trace pre-filtering.
  - symbolize.py: High-level coordinator and CLI entry point.
- Convert tools/valgrind/asan/asan_symbolize.py into a thin wrapper delegating
  to starboard.tools.symbolize.
- Expand test suite in starboard/tools/symbolize/symbolize_test.py to 39 unit/integration/benchmark
  tests (< 2.0s for 1,000+ frames).
- Add baseline unit tests in tools/valgrind/asan/asan_symbolize_test.py (17 tests).
- Wire asan_symbolize_test.py into .github/actions/symbolize_test/action.yaml.
- Add comprehensive documentation in starboard/tools/symbolize/README.md.

Bug: 524687034
Bug: 560199756
- Address type fragility in symbolize.py by safely accepting integer and string values for base_address.
- Switch from parse_known_args() to parse_args() in symbolize.py to catch unrecognized CLI flags.
- Remove redundant shebang lines from library modules (detector.py, formats.py, json_processor.py, runner.py).
- Make FormatHandler an explicit abstract base class inheriting from abc.ABC with @abc.abstractmethod.
- Use str.partition() for path prefix stripping in formats.py.
- Define AddressMode enum for latched resolution modes in detector.py.
- Narrow exception handling in json_processor.py and runner.py to specific exception types.
- Expose AddressMode, symbolize_stream, and symbolize_string in starboard.tools.symbolize.__all__.
- Remove redundant (object) inheritance and Python 2 unicode literals in asan_symbolize.py.
- Add unit test verifying integer base_address handling in symbolize_test.py.
- Extract library basename in AndroidFormatHandler to track originating binaries.
- Avoid querying default library for frames from unrelated external libraries (e.g. system libc) to prevent false-positive symbol collisions.
- Support reading stack traces from sys.stdin when --filename is omitted.
- Add unit tests for mixed-library stack traces and stdin CLI execution.
Add _RE_COBALT_INVERTED regex to CobaltFormatHandler to support both raw
'<unknown> [0x<addr>]' frames and previously-symbolized
'0x<addr> [<symbol>]' frames, making Cobalt stack trace symbolization
idempotent and compatible with RDK and post-processed crash logs.
- Address PR review findings:
  1. Fix dead code and refine address mode logic in StreamingSessionTracker.resolve_offset().
  2. Propagate strip_prefixes parameter through FormatHandler.format().
  3. Require 'in' keyword in GDB frame regex to avoid false positives.
  4. Support demangled C++ symbol signatures with spaces in CobaltFormatHandler.
  5. Use atomic temporary file replacement and early exit in process_test_summary_json().
  6. Standardize inlined frames with '(inlined)' suffix across formats.
- Add comprehensive regression tests for findings 1-6 in symbolize_test.py.
- Add detailed explanations of relative vs absolute address mode, multi-frame
  probing rationale, and entry keyword heuristics in detector.py.
- Add format examples for all FooFormatHandler classes and _RE_* regex constants,
  and document FrameMatch attributes in formats.py.
- Document LLVM symbolizer stdin/stdout protocol, input query formatting, and
  output parsing with examples in runner.py.
- Document the __all__ export list and public module interface in symbolize.py.
- Restore and adapt descriptive code comments across asan_symbolize.py.
- Inline test fixtures in asan_symbolize_test.py and symbolize_test.py, and remove
  the testdata/ directories to make tests completely self-contained.

@arjungm arjungm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is a wonderful qol addition

@jellefoks
jellefoks merged commit 6d33298 into youtube:main Sep 30, 2026
683 of 687 checks passed
@github-actions github-actions Bot added the cp-27.lts Cherry Pick to the 27.lts branch label Sep 30, 2026
briantting pushed a commit that referenced this pull request Sep 30, 2026
Refer to original PR: #12585

starboard: Modularize and unify symbolizer tools

Refactor the symbolization toolset by decomposing logic into a high-
performance modular package. This introduces a centralized runner for
llvm-symbolizer with persistent subprocesses and caching, a registry
for diverse log formats, and dynamic address detection.

Convert asan_symbolize.py into a thin wrapper to maintain backward
compatibility while leveraging the new core. This architecture
improves maintainability and provides a unified interface for parsing
Android logcats, Cobalt stack dumps, and GDB outputs.

Bug: 524687034
Bug: 560199756
TAG=agy
CONV=8b5d7c17-137f-4cec-9795-2e00ef8ddffc

(cherry picked from commit 6d33298)
@oxve oxve removed the cp-27.lts Cherry Pick to the 27.lts branch label Oct 5, 2026
briantting pushed a commit that referenced this pull request Oct 16, 2026
Refer to original PR: #12585

starboard: Modularize and unify symbolizer tools

Refactor the symbolization toolset by decomposing logic into a high-
performance modular package. This introduces a centralized runner for
llvm-symbolizer with persistent subprocesses and caching, a registry
for diverse log formats, and dynamic address detection.

Convert asan_symbolize.py into a thin wrapper to maintain backward
compatibility while leveraging the new core. This architecture
improves maintainability and provides a unified interface for parsing
Android logcats, Cobalt stack dumps, and GDB outputs.

Bug: 524687034
Bug: 560199756
TAG=agy
CONV=8b5d7c17-137f-4cec-9795-2e00ef8ddffc

(cherry picked from commit 6d33298)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants