6 let s:ScriptLocation = expand("<sfile>")
22 #Breakpoint positions: List of dictionaries of form
23 #{"signnum" : , "file" : , "lineno":, "cond" : }
29 global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread
32 clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip()
35 if clientcmd.strip()=="":
36 print "No command given!"
39 #Add the breakpoints to the configuration
40 conf = Configuration.Configuration()
41 conf.load(".pygdb.conf")
43 conf.addBreak(bp["file"], bp["lineno"], bp["cond"])
44 conf.store(".pygdb.conf")
46 vim.command("!python %s/pygdb.py %s &\n" % (pygdbdir, clientcmd))
49 def gdbToggleBreakpoint(lineno=None, file=None):
52 #Set lineno and file if not already set
54 lineno = vim.current.window.cursor[0]
56 file = getCurrentFile()
58 #Determine index of breakpoint
59 bpidx = gdbGetBreakpoint( file, lineno )
61 #Remove the breakpoint
63 vim.command("sign unplace %(signnum)d" % gdbBps[bpidx])
66 #Create the breakpoint
68 #Determine a sign number
69 signnum = gdbNewSignnum()
71 #Create breakpoint and add sign
72 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : None}
73 vim.command("sign place %(signnum)d line=%(lineno)d name=BreakPoint file=%(file)s" % b)
77 def gdbBreakpointCond(lineno=None, file=None, cond=None):
80 #Set lineno and file if not already set
82 lineno = vim.current.window.cursor[0]
84 file = getCurrentFile()
86 #Determine index of breakpoint
87 bpidx = gdbGetBreakpoint( file, lineno )
89 #Remove the breakpoint
92 cond = vim.eval("input('Breakpoint condition: ', '%s')" % gdbBps[bpidx]["cond"])
93 gdbBps[bpidx]["cond"] = cond
96 #Determine a sign number
97 signnum = gdbNewSignnum()
101 cond = vim.eval("input('Breakpoint condition: ', '')")
103 #Create breakpoint and add sign
104 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : cond}
105 vim.command("sign place %(signnum)d line=%(lineno)d name=CondBreakPoint file=%(file)s" % b)
109 def getCurrentFile():
110 return vim.current.window.buffer.name
120 def gdbGetBreakpoint(file, lineno):
121 for i in range(len(gdbBps)):
122 if [gdbBps[i]["file"], gdbBps[i]["lineno"]] == [file,lineno]:
130 highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black
132 sign define BreakPoint text=! texthl=BreakPoint linehl=BreakPoint
133 sign define CondBreakPoint text=? texthl=BreakPoint linehl=BreakPoint
137 command! GDBLaunch :python gdbLaunch()
138 command! GDBToggleBreakpoint :python gdbToggleBreakpoint()
139 command! GDBBreakpointCond :python gdbBreakpointCond()
143 function! GDBMapDefaults()
144 nmap <silent> <F5> :GDBLaunch<CR>
145 nmap <silent> <F8> :GDBToggleBreakpoint<CR>
146 nmap <silent> <F9> :GDBBreakpointCond<CR>