I am trying to set up a shortcut that allows me to start gdb from within neovim while selecting the executable that I want to debug via fzf. Using the following command

com! -bar -bang Debugger call fzf#run(fzf#wrap({'source': ' find build/ -perm -111 -type f', 'sink': 'Termdebug'}))

I can select the executable and start it in Termdebug, but for some reason, neovim does not load the package correctly. All related commands such as Break, Step etc are undefined and if I add a breakpoint within the gdb terminal, neovim shows a long list of missing variables.

  • 1
    To debug maybe try replacing 'Termdebug' with a test command that just prints the args like command! -nargs=1 Printargs echom <f-args>. Then you will know for sure what's being passed to Termdebug... – B Layer Dec 3 '20 at 6:16
  • I have no idea what this does. – Christian Brabandt Dec 3 '20 at 8:41
  • I tried that and the args for Termdebug are as expected, i.e. solely the name of the file to run Termdebug with. I think it might have something to do with how fzf handles the sink, but I am not sure. – Philipp Krenz Dec 3 '20 at 14:15
  • Welcome to Vi and Vim! – D. Ben Knoble Dec 3 '20 at 21:12
  • Been a decade or so since I ran gdb so I'm guessing here, but are there any configuration files that are picked up normally by gdb but aren't in this context. In general, think about ways the shell environment may differ between a shell you launch manually and one that Vim launches. Also, I know you can pass flags to gdb through Termdebug so pass whatever debug/verbose flags you can think of and also, if stderr output is relevant here, make sure it is being captured in a file so you can find it afterwards. What about inside gdb...any diagnostic commands that might shed light on the problem? – B Layer Dec 3 '20 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.