6 let s:ScriptLocation = expand("<sfile>")
18 #Do not use a ~ for home directory
19 pygdbdir = "/home/shuber/projekte/pygdb"
20 sys.path.append(pygdbdir)
26 #Breakpoint positions: List of dictionaries of form {"signnum" : , "file" : , "lineno":, "cond" : }
32 global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread
35 clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip()
38 if clientcmd.strip()=="":
39 print "No command given!"
42 #Add the breakpoints to the configuration
43 conf = Configuration.Configuration()
44 conf.load(".pygdb.conf")
46 conf.addBreak(bp["file"], bp["lineno"], bp["cond"])
47 conf.store(".pygdb.conf")
49 vim.command("!python %s/pygdb.py %s &\n" % (pygdbdir, clientcmd))
52 def gdbToggleBreakpoint(lineno=None, file=None):
55 #Set lineno and file if not already set
57 lineno = vim.current.window.cursor[0]
59 file = vim.current.window.buffer.name
61 #Determine index of breakpoint
62 bpidx = gdbGetBreakpoint( file, lineno )
64 #Remove the breakpoint
66 vim.command("sign unplace %(signnum)d" % gdbBps[bpidx])
69 #Create the breakpoint
71 #Determine a sign number
72 signnum = gdbNewSignnum()
74 #Create breakpoint and add sign
75 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : None}
76 vim.command("sign place %(signnum)d line=%(lineno)d name=BreakPoint file=%(file)s" % b)
80 def gdbBreakpointCond(lineno=None, file=None, cond=None):
83 #Set lineno and file if not already set
85 lineno = vim.current.window.cursor[0]
87 file = vim.current.window.buffer.name
89 #Determine index of breakpoint
90 bpidx = gdbGetBreakpoint( file, lineno )
92 #Remove the breakpoint
95 cond = vim.eval("input('Breakpoint condition: ', '%s')" % gdbBps[bpidx]["cond"])
96 gdbBps[bpidx]["cond"] = cond
99 #Determine a sign number
100 signnum = gdbNewSignnum()
104 cond = vim.eval("input('Breakpoint condition: ', '')")
106 #Create breakpoint and add sign
107 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : cond}
108 vim.command("sign place %(signnum)d line=%(lineno)d name=CondBreakPoint file=%(file)s" % b)
118 def gdbGetBreakpoint(file, lineno):
119 for i in range(len(gdbBps)):
120 if [gdbBps[i]["file"], gdbBps[i]["lineno"]] == [file,lineno]:
128 highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=White
129 highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black
131 sign define ExecutionLine text==> texthl=ExecutionLine linehl=ExecutionLine
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>