
rust-debugging
by huynq55-v2
SKILL.md
name: Rust Debugging description: Tools and commands for debugging Rust OS kernel, UEFI bootloader, and user-space programs.
Rust Debugging Skill
This skill provides commands and workflows for inspecting binaries and debugging the OS components on Linux.
Prerequisites
- LLVM Tools: Ensure
llvm-tools-previewis installed:rustup component add llvm-tools-preview - Rust Object Tools: Recommended usage via
rust-objdump,rust-nm, or standardllvm-*tools found in your Rust toolchain. - GDB: Ensure
gdborrust-gdbis installed (sudo apt install gdb).
1. User Space Debugging (Static Musl Binaries)
For user space programs compiled with x86_64-unknown-linux-musl and crt-static.
List Symbols (nm)
To see all symbols in a binary (with Rust demangling):
rust-nm <BINARY>
# Or using standard nm (demangle with rustfilt if installed)
nm <BINARY> | rustfilt
Disassemble (objdump)
To view the assembly instructions. rust-objdump automatically demangles names:
rust-objdump -d <BINARY>
Look for _start or main to verify the entry point.
Check ELF Headers (readobj)
To verify if it's a valid statically linked ELF:
rust-readobj -h <BINARY>
2. Kernel & Bootloader Debugging
Inspect Initial RAM Disk / UEFI Payload
Use llvm-objdump to check the kernel binary structure before it gets packed.
rust-objdump -h target/x86_64-unknown-none/release/kernel
QEMU + GDB Debugging
To debug the running kernel with GDB:
-
Launch QEMU with GDB Stub: Add
-s -Sto your QEMU command.-s: Shorthand for-gdb tcp::1234-S: Freeze CPU at startup (wait for debugger)
-
Attach GDB: Open a new terminal and run:
rust-gdb target/x86_64-unknown-none/debug/kernel(Ensure you point to the compiled kernel binary to load symbols)
-
Connect to QEMU: Inside GDB:
target remote :1234 break _start continue
QEMU Monitor
When QEMU is running:
- Press
Ctrl+Alt+2to switch to the QEMU Monitor. - Type
info registersto see CPU state. - Type
info memto see memory mappings (if supported). - Press
Ctrl+Alt+1to return to the display.
3. Common Cargo Commands
- Check Code:
cargo check - Clippy:
cargo clippy - Macro Expansion:
cargo expand(requirescargo-expandcrate)
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です