SchroSIM Debugging Guide
1) Debug Rust GUI in CLion
Prerequisites
- Open the repo root (
SchroSIM) in CLion. - Use the Cargo project at
Cargo.toml(workspace root).
Run configuration
- Create a new
Cargorun configuration: Command:runPackage:schrosim-guiWorking directory:$ProjectFileDir$- Add environment variables:
RUST_BACKTRACE=1(also enforced via.cargo/config.toml)- Optional for Swift attach flow:
SCHROSIM_WAIT_SWIFT_DEBUGGER=1 - Start with
Debug(notRun).
Breakpoints to set
core-rust/schrosim-gui/src/main.rsatfn run_cli(...)core-rust/schrosim-gui/src/main.rsatfn parse_cli_output(...)(JSON parsing logic)core-rust/schrosim-gui/src/main.rsinsideimpl eframe::App for SchroSimApp->fn update(...)
Verify breakpoints are hit
- Launch debugger in CLion.
- In GUI, click
Run circuit. - Confirm debugger stops in
update, then inrun_cli, then inparse_cli_output.
2) Attach Xcode Debugger to Swift CLI Spawned by Rust GUI
Enable wait mode
- Start Rust GUI from CLion with:
SCHROSIM_WAIT_SWIFT_DEBUGGER=1
When GUI invokes CLI, schrosim-cli is launched with --wait-debugger and pauses itself via SIGSTOP.
Attach from Xcode
- Open Xcode.
- Choose
Debug->Attach to Process by PID or Name.... - Enter
schrosim-cliand attach. - Press
Continuein Xcode to resume the paused CLI process.
Swift breakpoints
core-swift/Sources/schrosim-cli/main.swiftatwaitForDebuggerIfRequested(...)core-swift/Sources/schrosim-cli/main.swiftat JSON decode line inhandleRun(...)core-swift/Sources/schrosim-cli/main.swiftatemitJSON(...)
Verify
- With Rust GUI running under CLion debug, click
Run circuit. - Attach Xcode to
schrosim-cli. - Confirm Swift breakpoints trigger, then Rust returns to
parse_cli_output.
3) Rust Workspace Layout
Rust is configured as a workspace at repo root, with crates in core-rust/:
Cargo.toml # workspace + dev profile (debug symbols on)
core-rust/schrosim-gui/ # member crate
To add more Rust crates later, create a crate directory and add it to members in root Cargo.toml.
4) Fix swift test / XCTest in CLion
If swift test fails with no such module 'XCTest', CLion is typically using only Command Line Tools (/Library/Developer/CommandLineTools).
Required setup
- Install full Xcode (App Store or Developer download).
- In CLion, use the shared run config:
Swift Test (core-swift). - If your Xcode path differs, edit
DEVELOPER_DIRin that run config.
Shared assets in repo:
- Script: scripts/swift-test.sh
- Run config: .run/Swift Test (core-swift).run.xml
The script auto-selects Xcode.app or Xcode-beta.app, sets SDKROOT=macosx, and runs swift test.