The SAMD51 and ESP32 both have "JTAG" debugging connections. The SAMD51 has its SWD broken-out to the inner 0.05" header, and the ESP32 is connected to SAMD51 GPIO.
The inner 0.05" header is designed to interface directly with Segger J-link (or similar) pinouts.
Connection to a J-Link EDU mini looks like this:
More specifically, I use a 2x2 block of male 0.05" headers in combination with any 0.05" cable I can get my hands on. Close-up with annotations below:
If you're using a Segger J-Link with 0.1" headers, it's convenient to use something like the Adafruit J-Link breakout board to set-down to 0.05" pitch: