6 let s:ScriptLocation = expand("<sfile>")
19 #Do not use a ~ for home directory
20 pygdbdir = "/home/shuber/projekte/pygdb"
21 sys.path.append(pygdbdir)
27 #Breakpoint positions: List of dictionaries of form
28 #{"signnum" : , "file" : , "lineno":, "cond" : }
34 global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread
37 clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip()
40 if clientcmd.strip()=="":
41 print "No command given!"
44 #Add the breakpoints to the configuration
45 conf = Configuration.Configuration()
46 conf.load(".pygdb.conf")
48 conf.addBreak(bp["file"], bp["lineno"], bp["cond"])
49 conf.store(".pygdb.conf")
51 vim.command("!python %s/pygdb.py %s &\n" % (pygdbdir, clientcmd))
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 = getCurrentFile()
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 = getCurrentFile()
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)
114 def getCurrentFile():
115 splitted = string.split(vim.current.window.buffer.name, os.sep)
126 def gdbGetBreakpoint(file, lineno):
127 for i in range(len(gdbBps)):
128 if [gdbBps[i]["file"], gdbBps[i]["lineno"]] == [file,lineno]:
136 highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=White
137 highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black
139 sign define ExecutionLine text==> texthl=ExecutionLine linehl=ExecutionLine
140 sign define BreakPoint text=! texthl=BreakPoint linehl=BreakPoint
141 sign define CondBreakPoint text=? texthl=BreakPoint linehl=BreakPoint
145 command! GDBLaunch :python gdbLaunch()
146 command! GDBToggleBreakpoint :python gdbToggleBreakpoint()
147 command! GDBBreakpointCond :python gdbBreakpointCond()
151 function! GDBMapDefaults()
152 nmap <silent> <F5> :GDBLaunch<CR>
153 nmap <silent> <F8> :GDBToggleBreakpoint<CR>
154 nmap <silent> <F9> :GDBBreakpointCond<CR>