Why call find-file-noselect there? If this is meant to operate on the
file that was just visited, it already has a buffer, and it is the
current buffer when gdb-find-file-hook runs. Why not just use
that buffer?
That might have been true but I'm now using this function to address Kim's
point about enabling gud-minor-mode for existing buffers.
I don't understand this explanation. In the case where you're enabling
gud-minor-mode in existing buffers, the buffers also already exist so you
shouldn't call find-file-noselect (which may cause new files to be visited).
Maybe you want something like find-buffer-visiting, but even that sounds
doubtful because it seems that you always know the buffer before you even
know the file name