Skip to content

Comments

Add backtrace infrastructure and binary analysis tooling#29

Merged
zouguangxian merged 1 commit intomainfrom
gx/improve-backtrace
Feb 15, 2026
Merged

Add backtrace infrastructure and binary analysis tooling#29
zouguangxian merged 1 commit intomainfrom
gx/improve-backtrace

Conversation

@zouguangxian
Copy link
Collaborator

Summary

This PR adds comprehensive backtrace and binary analysis capabilities to ZeroOS:

New Infrastructure

  • zeroos-backtrace crate: Frame pointer and DWARF-based backtrace support
  • elf-report crate: Binary size analysis and symbol mapping tool
  • analyze_backtrace command: Analyze backtrace output from binaries
  • build-backtrace.sh: Build script for backtrace-enabled binaries

Improved Tooling

  • check_workspace: Enforce workspace consistency rules on package versions
  • massage: Run common cargo tasks (fix, clippy, fmt, check, test) on packages
  • spike_syscall_instcount: Measure syscall instruction counts from Spike logs
  • Reorganized xtask commands under cmds/ module

Other Improvements

  • Enhanced pre-commit hook with automatic PATH expansion for tool discovery
  • Improved error messages when tools are missing
  • Updated runtime panic handling to support backtraces
  • Build system and linker configuration improvements
  • Added AGENTS.md documentation

Test Plan

  • Build with backtrace support: ./build-backtrace.sh
  • Run binary size analysis: cargo run -p elf-report -- <binary>
  • Test xtask commands: cargo xtask check_workspace, cargo xtask massage
  • Verify pre-commit hook works with PATH expansion

Changes

  • 47 files changed, 2802 insertions(+), 78 deletions(-)
  • New crates: zeroos-backtrace, elf-report
  • Updated runtime crates to integrate backtrace support

@cursor
Copy link

cursor bot commented Feb 15, 2026

PR Summary

High Risk
Touches core build/linker configuration and panic/backtrace paths across runtimes, with new unsafe stack-walking code and new cfg-driven compilation modes that could affect guest binaries and debugging behavior.

Overview
Adds a new zeroos-backtrace crate and wires runtimes/platform panic paths to a single Backtrace interface selected via cfg(zeroos_backtrace) (off, dwarf, frame_pointers), replacing the prior feature-gated backtrace plumbing.

Updates zeroos-build to expose explicit backtrace modes on cargo spike build, set the corresponding cfg + required RUSTFLAGS (unwind tables vs frame pointers), and rename linker/target-spec templating from backtrace to EMIT_UNWIND_TABLES so .eh_frame emission is controlled independently.

Introduces a new elf-report crate (CLI + library) to inspect ELF section sizes and largest .text/.rodata symbols, with optional GNU ld map parsing for stripped binaries, and adds an xtask analyze-backtrace command to build a matrix of backtrace configurations and report size deltas using elf-report.

Improves developer workflow by enhancing the Rust pre-commit hook (better exec error messages, PATH expansion, workspace check + matrix fix/clippy/check task ordering) and updating build scripts/matrix config to use the new backtrace modes.

Written by Cursor Bugbot for commit f659716. This will update automatically on new commits. Configure here.

@socket-security
Copy link

socket-security bot commented Feb 15, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​object@​0.36.78110093100100
Addedcargo/​rustc-demangle@​0.1.2710010093100100

View full report

zouguangxian added a commit that referenced this pull request Feb 15, 2026
- Only set RUST_BACKTRACE=full in DWARF mode (not in off/frame-pointers)
- Fix temp file cleanup in build-backtrace.sh to include all temp files

Fixes issues raised in PR #29 review.
@zouguangxian zouguangxian force-pushed the gx/improve-backtrace branch 3 times, most recently from 86ff3f1 to 0993b2e Compare February 15, 2026 07:03
@zouguangxian zouguangxian force-pushed the gx/improve-backtrace branch 3 times, most recently from e1211f6 to 04d7b52 Compare February 15, 2026 08:50
Add comprehensive backtrace and binary size analysis capabilities:

- **New crate: zeroos-backtrace** - Frame pointer and DWARF-based backtraces
- **New crate: elf-report** - Binary size analysis and symbol mapping
- **New command: analyze_backtrace** - Analyze backtrace output from binaries
- **New build script: build-backtrace.sh** - Build binaries with backtrace support

Improve xtask tooling:
- Add `check_workspace` to enforce workspace consistency rules
- Add `massage` to run cargo tasks on specified packages
- Add `spike_syscall_instcount` to measure syscall instruction counts
- Reorganize xtask commands under `cmds/` module

Other improvements:
- Update pre-commit hook for better error handling
- Add AGENTS.md documentation
- Update runtime panic handling to support backtraces
- Improve build system and linker configuration
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@zouguangxian zouguangxian merged commit 1c37055 into main Feb 15, 2026
16 checks passed
@zouguangxian zouguangxian deleted the gx/improve-backtrace branch February 15, 2026 09:17
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.

2 participants