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
44 clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd)
46 gdbterm, mainctrlwnd, statuswnd = pygdb.launchDebugger(clientcmd, False)
49 statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"])
55 def gdbToggleBreakpoint(lineno=None, file=None):
58 #Set lineno and file if not already set
60 lineno = vim.current.window.cursor[0]
62 file = vim.current.window.buffer.name
64 #Determine index of breakpoint
65 bpidx = gdbGetBreakpoint( file, lineno )
67 #Remove the breakpoint
69 vim.command("sign unplace %(signnum)d" % gdbBps[bpidx])
72 #Create the breakpoint
74 #Determine a sign number
75 signnum = gdbNewSignnum()
77 #Create breakpoint and add sign
78 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : None}
79 vim.command("sign place %(signnum)d line=%(lineno)d name=BreakPoint file=%(file)s" % b)
83 def gdbBreakpointCond(lineno=None, file=None, cond=None):
86 #Set lineno and file if not already set
88 lineno = vim.current.window.cursor[0]
90 file = vim.current.window.buffer.name
92 #Determine index of breakpoint
93 bpidx = gdbGetBreakpoint( file, lineno )
95 #Remove the breakpoint
98 cond = vim.eval("input('Breakpoint condition: ', '%s')" % gdbBps[bpidx]["cond"])
99 gdbBps[bpidx]["cond"] = cond
102 #Determine a sign number
103 signnum = gdbNewSignnum()
107 cond = vim.eval("input('Breakpoint condition: ', '')")
109 #Create breakpoint and add sign
110 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : cond}
111 vim.command("sign place %(signnum)d line=%(lineno)d name=CondBreakPoint file=%(file)s" % b)
121 def gdbGetBreakpoint(file, lineno):
122 for i in range(len(gdbBps)):
123 if [gdbBps[i]["file"], gdbBps[i]["lineno"]] == [file,lineno]:
131 highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=White
132 highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black
134 sign define ExecutionLine text==> texthl=ExecutionLine linehl=ExecutionLine
135 sign define BreakPoint text=! texthl=BreakPoint linehl=BreakPoint
136 sign define CondBreakPoint text=? texthl=BreakPoint linehl=BreakPoint
140 command! GDBLaunch :python gdbLaunch()
141 command! GDBToggleBreakpoint :python gdbToggleBreakpoint()
142 command! GDBBreakpointCond :python gdbBreakpointCond()
146 function! GDBMapDefaults()
147 nmap <silent> <F5> :GDBLaunch<CR>
148 nmap <silent> <F8> :GDBToggleBreakpoint<CR>
149 nmap <silent> <F9> :GDBBreakpointCond<CR>