Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Command-line interface

v5gdb has a command line interface that can debug your V5 brain over a USB connection. It’s intended for use with the StdioTransport; if you make a custom transport, you will have to make your own alternative.

Usage

The arguments to v5gdb are the ELF files that describe the program which is currently running on the brain. All frameworks for the VEX V5 output these files as part of their build process, but they are placed in varying locations.

For PROS programs, specifying ELF files is optional; v5gdb can usually automatically discover them.

Example usage:

# PROS
v5gdb

# PROS (with ELF files specified; optional)
v5gdb ./bin/hot.package.elf ./bin/cold.package.elf

# vexide
v5gdb ./target/armv7a-vex-v5/release/your_program_name

Command-line Options

-c <client>, --client <client> (Debugger Client)

environment variable: V5GDB_CLIENT

This flag allows you to specify the path or name of a custom GDB or LLDB program which v5gdb should use. This option is useful if your installation of GDB/LLDB has a non-standard name which v5gdb does not detect by default.

For example, to use Rust GDB instead of GDB:

v5gdb -c rust-gdb

Whatever you pass must accept GDB’s command-line arguments (or LLDB’s, if --lldb is specified or the client name contains lldb).

This option has no effect in TCP mode.

Automatic Discovery

If this option is not specified, v5gdb will check for the following programs and use the first one it finds:

  1. arm-none-eabi-gdb
  2. GDB from the PROS Toolchain in the PROS_TOOLCHAIN env variable
  3. GDB from the PROS Toolchain installed by the PROS VS Code extension (“OneClick”)
  4. gdb-multiarch
  5. gdb

Or, if --lldb is specified, these programs will be checked:

  1. lldb

-C=<arg>, --client-arg=<arg> (Debugger Client Arguments)

This flag passes an extra argument to the debugger client. It can be specified more than one time.

For example, to run GDB in “quiet” mode with its TUI interface enabled:

v5gdb -C=--quiet -C=--tui

--tcp <addr> (TCP Server mode)

By default, v5gdb CLI opens directly into the gdb command-line REPL interface. If you’d like to use a custom GDB frontend, you can disable this behavior by specifying the --tcp flag, which makes v5gdb CLI run headless (similarly to gdbserver).

v5gdb --tcp=localhost:35537

When the --tcp flag is specified, v5gdb will start a TCP server and wait for a connection on the specified address and port. You can connect to it from a GDB frontend like this:

$ gdb -ex "target remote :35537" bin/monolith.elf
Reading symbols from bin/monolith.elf...
Remote debugging using :35537
(gdb)

When v5gdb starts GDB itself, it runs a few setup commands before connecting that help improve the performance of memory reads. In TCP Server mode, we recommend running these commands yourself (before target remote):

mem 0x100000 0x2c00000 ro cache
mem 0x2c00000 0x8000000 rw cache
set dcache line-size 1024

For example:

gdb -ex "mem 0x100000 0x2c00000 ro cache" \
    -ex "mem 0x2c00000 0x8000000 rw cache" \
    -ex "set dcache line-size 1024" \
    -ex "target remote :35537" \
    bin/monolith.elf

The above example just uses GDB like normal, but TCP Server mode can be useful for integrating v5gdb with an IDE or code editor to set up graphical debugging.

In TCP Server mode, logs and other serial output from the program you are debugging will appear under the v5gdb command instead of being interleaved with your GDB session.

--lldb (Use LLDB)

While GDB is v5gdb’s best-supported debugger, you can also use it with LLDB instead by specifying this flag.

Tip

LLDB mode is turned on automatically if you choose a client whose name includes lldb, such as v5gdb -c rust-lldb.

TCP Server mode and LLDB

In TCP Server mode, this flag isn’t supported; however, you can connect LLDB yourself with these commands:

$ lldb
(lldb) settings set target.process.memory-cache-line-size 1024
(lldb) target create bin/monolith.elf
(lldb) gdb-remote 35537

To debug more than one ELF file (e.g. PROS’s hot.package.elf and cold.package.elf), load each extra file after connecting:

(lldb) target modules add bin/cold.package.elf
(lldb) target modules load --file bin/cold.package.elf --slide 0

Compatibility

LLDB can’t call functions in expressions because it disables remote code execution on bare-metal targets. Reading variables and simple expressions like x * 2 work, though.

--no-discover-elf (ELF auto-discovery)

environment variable: V5GDB_NO_DISCOVER_ELF

By default, if no ELF files are specified on the command line, v5gdb will search common locations in PROS projects for debug info stored in ELF files, including bin/monolith.elf, bin/hot.package.elf, and bin/cold.package.elf.

You can disable this feature using the --no-discover-elf command-line flag. ELF auto-discovery is always disabled in TCP Server mode.

--user-io <mode> (User I/O packet format)

environment variable: V5GDB_USER_IO

PROS adds extra COBS encoding to all data written to stdout, which can make your prints look odd when v5gdb does not recognize that it needs to decode your program’s output. This flag customizes how v5gdb interprets your program’s output.

Supported modes:

  • --user-io auto (default): When v5gdb is running inside a PROS project, it will apply PROS-style program output decoding.
  • --user-io pros: v5gdb will always apply PROS-style program output decoding.
  • --user-io raw: v5gdb will not apply any additional processing to program output.

--debug-io

Enables TRACE-level logging for serial operations. All decoding errors and serial I/O will be logged.

This is the same as adding v5gdb::serial=trace to the V5GDB_LOG environment variable.

Logging

You can use the V5GDB_LOG environment variable to customize logging. Format details are available here.

Example:

$ V5GDB_LOG=debug v5gdb