スキル一覧に戻る
huynq55-v2

rust-debugging

by huynq55-v2

0🍴 0📅 2026年1月15日
GitHubで見るManusで実行

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-preview is installed:
    rustup component add llvm-tools-preview
    
  • Rust Object Tools: Recommended usage via rust-objdump, rust-nm, or standard llvm-* tools found in your Rust toolchain.
  • GDB: Ensure gdb or rust-gdb is 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:

  1. Launch QEMU with GDB Stub: Add -s -S to your QEMU command.

    • -s: Shorthand for -gdb tcp::1234
    • -S: Freeze CPU at startup (wait for debugger)
  2. 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)

  3. Connect to QEMU: Inside GDB:

    target remote :1234
    break _start
    continue
    

QEMU Monitor

When QEMU is running:

  • Press Ctrl+Alt+2 to switch to the QEMU Monitor.
  • Type info registers to see CPU state.
  • Type info mem to see memory mappings (if supported).
  • Press Ctrl+Alt+1 to return to the display.

3. Common Cargo Commands

  • Check Code: cargo check
  • Clippy: cargo clippy
  • Macro Expansion: cargo expand (requires cargo-expand crate)

スコア

総合スコア

40/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です