Skip to content

Instantly share code, notes, and snippets.

@mattkretz
Created February 9, 2022 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattkretz/64ede954c31835837a0406b273be3aaf to your computer and use it in GitHub Desktop.
Save mattkretz/64ede954c31835837a0406b273be3aaf to your computer and use it in GitHub Desktop.
vim command "hack" to debug g++ in termdebug.vim
function! s:DebugGcc()
let file = expand("%:p")
let p = substitute(file, '/src/gcc-[^/]\+\zs/.*$', '', '').'/obj/gcc'
let driver = p.'/xg++'
let tmp = systemlist(driver.' "-###" -S -o- -O2 -std=c++20 -B '.p.' -I'.p.'/../x86_64-pc-linux-gnu/libstdc++-v3/include -I'.p.'/../x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu '.file)
let cc1plus = split(filter(tmp, 'v:val =~ "cc1plus"')[0], '\s\+')
execute "Termdebug ".cc1plus[0]
execute "Arguments ".join(cc1plus[1:], ' ')
call TermDebugSendCommand("source ".p."/.gdbinit")
endfunction
command! DebugGcc call s:DebugGcc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment