OK, I have solved it. Please revise the documentation page accordingly:
The documentation page fails to note that you also need to edit the line in launch.json saying
"serverStarted":
You must tell it the last thing the gdb server prints after starting up.
Using openocd and a NucleoF411RE, for example, this would be
"serverStarted": "adapter speed: 4000 kHz",
where you need to put double backslashes in front of each space (cant format that here!)
For the sake of completeness here, I also have
"debugServerArgs": "-f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/board/st_nucleo_f4.cfg -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/interface/stlink-v2-1.cfg -c init -c \"reset init\""
(I suspect st-util would also work using a similar fix, but I also found out that the particular board I was using is not supported by st-util)
I have followed the instructions here: https://docs.mbed.com/docs/mbed-os-handbook/en/latest/debugging/vscode/ but whatever I do, I always get the error: Debugger executable '/usr/local/bin/arm-none-eabi-gdb' is not signed. As a result, debugging may not work properly.
This happens whether I try to use openocd as the debug server, or even st-util. VS code appears to fail to start up the debug server, and as a result arm-none-eabi-gdb cannot connect to it.
(The error message appears to be completely spurious).
Anyone else managed to get this to work on a Mac? Anyone even tried to get this to work on a Mac?
Further info: here is the last part of what appears in the debug console
1: (406) Starting: "/usr/local/bin/st-util" -p 3333
1: (20423) <-logout
ERROR: Unable to start debugging. Debug server process failed to initialize.
C disconnect: {"restart":false}