Created
March 6, 2017 08:36
-
-
Save ildus/882271b11243a0205bbd2a3ff4e4c518 to your computer and use it in GitHub Desktop.
psql, gdb and vim intergration
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! MakeGdbBreak() | |
let path = "break ".expand('%').":".line(".") | |
call writefile([path], "/tmp/gdb_breaks") | |
echo "Created ".path | |
endfunction | |
command! -bar GDBreak call MakeGdbBreak() | |
nnoremap <leader>b :GDBreak<cr> |
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
#!/usr/bin/env python3 | |
import sys | |
import subprocess | |
import re | |
pid = None | |
for line in sys.stdin: | |
m = re.search('\d{1}\d+', line) | |
if m: | |
pid = int(m.group(0)) | |
gdb_init = '''set pagination off | |
handle SIGUSR1 noprint nostop | |
handle SIGUSR2 noprint nostop | |
set history filename /tmp/gdb_history | |
set history save on | |
set breakpoint pending on | |
set print elements 0 | |
''' | |
with open('/tmp/gdb_init', 'w') as f: | |
f.write(gdb_init) | |
commands = '''source /tmp/gdb_breaks | |
attach %s | |
''' % pid | |
with open('/tmp/gdb_commands', 'w') as f: | |
f.write(commands) | |
#urxvt --hold -e sudo gdb -ix /tmp/gdb_init -x /tmp/gdb_commands --args postgres | |
subprocess.Popen(['urxvt', '-e', 'sudo', 'gdb', '-ix', '/tmp/gdb_init', | |
'-x', '/tmp/gdb_commands', '--args', 'postgres']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment