Created
February 9, 2022 11:26
-
-
Save mattkretz/64ede954c31835837a0406b273be3aaf to your computer and use it in GitHub Desktop.
vim command "hack" to debug g++ in termdebug.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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