Attached are patches to fix this in Emacs 27 and 28; they're essentially the same, but with slightly different contexts around the diff. I'm not sure if this is wanted for Emacs 27, but it's a small bugfix, and combined with my patch in bug#39408 (and the GNU ELPA version of Tramp to fix bug#44151), M-x gdb should work correctly for Tramp. For Emacs 28, this is the only outstanding issue (that I know of) preventing M-x gdb from working with Tramp. The problem here was that `gud-last-frame', set in `gdb-frame-handler', expects a local file path, so the full Tramp path was confusing it. (Note: I have a couple of patches in Tramp already that put me at the limit for patches without copyright assignment paperwork. However, I've already requested the form.)