Debugger for Rust: FireDBG

2024年のスタート。2024年も個人 blog を継続する。

FireDBG[^2] という Rust の Debugger を試す。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/569971/3b05adef-4d04-42f4-7d31-7529a64d85c4.png)

![star-history_firedbg.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/569971/834f7178-9044-83b4-a032-bde7819585d5.png)

https://github.com/danny-yamamoto/rust-api-samples-rocket

## tl;dr
- 現時点で調べる限りでは、FireDBG は、Apple シリコンの影響で Dev Container で動かせない。Cloud Workstations[^3] で FireDBG を検証した。
- `info: completed FireDBG self tests` このメッセージが表示されれば install は完了。
- `.ss` というファイルが出力される。そのファイルを FireDBG で開くと、VS Code の画面で debug できる。

## Environment
* Cloud Workstations
    * OS
        * Ubuntu 20.04.6 LTS
    * Rust
        * cargo 1.74.1 (ecb9851af 2023-10-18)
        * rustc 1.74.1 (a28077b28 2023-12-04)
        * rustup 1.26.0 (5af9b9484 2023-04-05)
    * IDE
        * Code-OSS

## Getting Started[^1]
```bash
user@rust:~/FireDBG.Rust.Testbench$ curl https://raw.githubusercontent.com/SeaQL/FireDBG.for.Rust/main/install.sh -sSf | sh
info: downloading FireDBG from `https://github.com/SeaQL/FireDBG.for.Rust/releases/download/1.74.2/x86_64-ubuntu20.04.tar.gz`
info: installing FireDBG binaries to `/home/user/.cargo/bin`
info: performing FireDBG self tests
     Tracing `firedbg.toml` config file not found, default settings will be applied
     Tracing debugger_self_test = { trace = "full" }
      Parsed 2 source files; re-cached 2 source files
   Compiling firedbg-lib v0.1.2
   Compiling debugger_self_test v1.74.2 (/home/user/.cargo/bin/firedbg-lib/debugger-self-test)
    Finished dev [unoptimized + debuginfo] target(s) in 1.76s
     Running `LD_LIBRARY_PATH="/home/user/.cargo/bin/firedbg-lib/lib" "/home/user/.cargo/bin/firedbg-debugger" "run" "/home/user/.cargo/bin/firedbg-lib/debugger-self-test/target/debug/debugger_self_test" "--workspace-root" "/home/user/.cargo/bin/firedbg-lib/debugger-self-test" "--output" "/home/user/.cargo/bin/firedbg-lib/debugger-self-test/output.firedbg.ss" "--package-name" "debugger_self_test" "--package" "./full"`
Testing call_chain
Testing for_range
Testing hash_map
Testing return_char
Testing return_enum
Testing return_value
Testing return_object
Testing return_option
Testing return_result
Testing return_struct
Testing return_pointer
Testing return_ref_mut
Testing fn_return
info: completed FireDBG self tests
user@rust:~/FireDBG.Rust.Testbench$
```

- REST API の実装で使用した Axum のコードを使用。
```bash
user@rust:~/rust-api-samples-rocket/axum$ firedbg list-target
   Upgrading FireDBG version

Available binaries are:
        axum
user@rust:~/rust-api-samples-rocket/axum$
```

```bash
user@rust:~/rust-api-samples-rocket/axum$ firedbg run axum
     Tracing `firedbg.toml` config file not found, default settings will be applied
     Tracing axum = { trace = "full" }
      Parsed 13 source files; re-cached 5 source files
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `LD_LIBRARY_PATH="/home/user/.cargo/bin/firedbg-lib/lib" "/home/user/.cargo/bin/firedbg-debugger" "run" "/home/user/rust-api-samples-rocket/axum/target/debug/axum" "--workspace-root" "/home/user/rust-api-samples-rocket/axum" "--output" "/home/user/rust-api-samples-rocket/axum/firedbg/target/axum-1704180031405.firedbg.ss" "--package-name" "axum" "--package" "./full"`
user@rust:~/rust-api-samples-rocket/axum$
```

FireDBG に関する検証は以上。

## BTW
FireDBG を M1 の VSCode Dev Container で動かす方法がまだ不明。

[^1]: https://firedbg.sea-ql.org/blog/2023-12-13-getting-started/
[^2]: https://firedbg.sea-ql.org/
[^3]: https://cloud.google.com/workstations/docs