6 let s:ScriptLocation = expand("<sfile>")
18 #Do not use a ~ for home directory
19 sys.path.append("/home/shuber/projekte/pygdb/")
23 import MainControlWindow
27 #Breakpoint positions: List of dictionaries of form {"signnum" : , "file" : , "lineno":, "cond" : }
40 global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread
43 clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd)
44 gdbterm, mainctrlwnd, statuswnd = pygdb.launchDebugger(clientcmd, False)
47 statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"])
49 print "Started dbg session."
51 print "Finished dbg session."
54 def gdbToggleBreakpoint(lineno=None, file=None):
57 #Set lineno and file if not already set
59 lineno = vim.current.window.cursor[0]
61 file = vim.current.window.buffer.name
63 #Determine index of breakpoint
64 bpidx = gdbGetBreakpoint( file, lineno )
66 #Remove the breakpoint
68 vim.command("sign unplace %(signnum)d" % gdbBps[bpidx])
71 #Create the breakpoint
73 #Determine a sign number
74 signnum = gdbNewSignnum()
76 #Create breakpoint and add sign
77 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : None}
78 vim.command("sign place %(signnum)d line=%(lineno)d name=BreakPoint file=%(file)s" % b)
82 def gdbBreakpointCond(lineno=None, file=None, cond=None):
85 #Set lineno and file if not already set
87 lineno = vim.current.window.cursor[0]
89 file = vim.current.window.buffer.name
91 #Determine index of breakpoint
92 bpidx = gdbGetBreakpoint( file, lineno )
94 #Remove the breakpoint
97 cond = vim.eval("input('Breakpoint condition: ', '%s')" % gdbBps[bpidx]["cond"])
98 gdbBps[bpidx]["cond"] = cond
101 #Determine a sign number
102 signnum = gdbNewSignnum()
106 cond = vim.eval("input('Breakpoint condition: ', '')")
108 #Create breakpoint and add sign
109 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : cond}
110 vim.command("sign place %(signnum)d line=%(lineno)d name=CondBreakPoint file=%(file)s" % b)
120 def gdbGetBreakpoint(file, lineno):
121 for i in range(len(gdbBps)):
122 if [gdbBps[i]["file"], gdbBps[i]["lineno"]] == [file,lineno]:
130 highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=White
131 highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black
133 sign define ExecutionLine text==> texthl=ExecutionLine linehl=ExecutionLine
134 sign define BreakPoint text=! texthl=BreakPoint linehl=BreakPoint
135 sign define CondBreakPoint text=? texthl=BreakPoint linehl=BreakPoint
139 command! GDBLaunch :python gdbLaunch()
140 command! GDBToggleBreakpoint :python gdbToggleBreakpoint()
141 command! GDBBreakpointCond :python gdbBreakpointCond()
145 function! GDBMapDefaults()
146 nmap <silent> <F5> :GDBLaunch<CR>
147 nmap <silent> <F8> :GDBToggleBreakpoint<CR>
148 nmap <silent> <F9> :GDBBreakpointCond<CR>