Cannot get a custom debug tool to launch

I trying to configure a custom debug environment that launches gdb-multiarch on the host which then connects to a remote target running on a teensy41 arm cortex m7 board.

This is my platformio.ini

platform = teensy
board = teensy41
framework = arduino
lib_deps = symlink:///home/roger/TeensyDebug
build_flags = -DUSB_DUAL_SERIAL -DGDB_DUAL_SERIAL

[env:myrelease]

[env:mydebug]
build_type = debug

monitor_port = /dev/serial/by-id/usb-Teensyduino_Dual_Serial_13251740-if00

debug_port = /dev/serial/by-id/usb-Teensyduino_Dual_Serial_13251740-if02
debug_speed = 115200

debug_tool = custom
debug_load_mode = manual
debug_server =
    /usr/bin/gdb-multiarch

debug_init_break =

debug_init_cmds = $DEBUG_PORT
    shell wait-for-debug-port $DEBUG_PORT
    target extended-remote $DEBUG_PORT
    $INIT_BREAK

    define pio_reset_run_target
    interrupt
    tbreak loop
    continue
    end

    define pio_restart_target
    echo Reset is undefined
    end

When I run this with pio debug -e mydebug platformio pesists in trying launch arm-none-eabi-gdb from the teensy toolchain not gdb-multiarch.

What am I doing wrong.

PlatformIO takes this as the “the program which will create a GDB server that our GDB client (arm-none-eabi-gdb) can connect to”, not as the arm-none-eabi-gdb binary to use. The debug server is usually OpenOCD, JLinkGDBServerExe, pyOCD, etc. In some cases, there is no explicit “debug server”, such as the case with “blackmagicprobe”. There, the GDB client is instructed directly to connect via a COM port to the target.

The platform determines the used GDB program by setting

so if you want to change that, you will need to write a small extra pre script that does

Import("env")
env.Replace(GDB="/usr/bin/gdb-multiarch")