-
Notifications
You must be signed in to change notification settings - Fork 19
Guides
This page will guide you through common steps to get the most out of our toolchain.
Unit tests are a fundamental tool to develop any software, especially when the complexity grows. Even though the Nintendo 3DS doesn't have official support for the test
crate, ctru-rs
implements a custom test runner, from which we can take some hints.
To run the ctru-rs
unit tests directly on the the console, you should build them via this command:
cargo 3ds test --package ctru-rs --lib
This runs the tests directly on the console using 3dslink
(you can specify --no-run
to just build the testing 3dsx
file). Because std
tests are sadly not working in the current state of our toolchain, we will specify --package ctru-rs
to only build this library's unit tests. Finally, we use --lib
to avoid building and running all examples, since 3dslink
can't send off multiple binaries.
The testing framework is incredibly raw, but that's to be expected, since the official Rust tools are made to be run on the host system and not in cross-compilation.
Thanks to Luma3DS, the most modern CFW around, we can debug programs in real time with gdb
. To do so you will need to install gdb
on your host computer and acquire the rust-gdb
script (it comes with your Rust installation).
On your console, follow these steps:
- Open the Homebrew Launcher on your modded 3DS
- Open the Rosalina Menu (the button combo to do this is usually
L + Down + Select
) - Select "Debugger options"
- Press "Enable debugger"
- Press "Force-debug next application at launch"
- Remember the remote port and IP address it tells you to use!
Now, on your computer:
- Run your application in
debug
mode (you can do this remotely usingcargo 3ds run
) - Once you run the program, the console should start waiting in a black screen.
- Locate the built
.elf
file (you can find it in thetarget
folder, usually attarget/armv6k-nintendo-3ds/debug/<app-name>.elf
)
With the file at hand, you can run this simple command:
rust-gdb <file-path>
With this you should find yourself in the normal gdb
CLI. If you want to connect to your 3DS, simply do
(gdb) target remote <ip-address>:<port>
And you're in! You can now use breakpoints, read memory, step or continue through the program as in normal gdb
. Thanks to rust-gdb
, you'll even have pretty notation for Rust types. Happy debugging!