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).strip()
46 if clientcmd.strip()=="":
47 print "No command given!"
50 gdbterm, mainctrlwnd, statuswnd = pygdb.launchDebugger(clientcmd, False)
53 statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"])
55 print "Started dbg session."
57 print "Finished dbg session."
60 def gdbToggleBreakpoint(lineno=None, file=None):
63 #Set lineno and file if not already set
65 lineno = vim.current.window.cursor[0]
67 file = vim.current.window.buffer.name
69 #Determine index of breakpoint
70 bpidx = gdbGetBreakpoint( file, lineno )
72 #Remove the breakpoint
74 vim.command("sign unplace %(signnum)d" % gdbBps[bpidx])
77 #Create the breakpoint
79 #Determine a sign number
80 signnum = gdbNewSignnum()
82 #Create breakpoint and add sign
83 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : None}
84 vim.command("sign place %(signnum)d line=%(lineno)d name=BreakPoint file=%(file)s" % b)
88 def gdbBreakpointCond(lineno=None, file=None, cond=None):
91 #Set lineno and file if not already set
93 lineno = vim.current.window.cursor[0]
95 file = vim.current.window.buffer.name
97 #Determine index of breakpoint
98 bpidx = gdbGetBreakpoint( file, lineno )
100 #Remove the breakpoint
103 cond = vim.eval("input('Breakpoint condition: ', '%s')" % gdbBps[bpidx]["cond"])
104 gdbBps[bpidx]["cond"] = cond
107 #Determine a sign number
108 signnum = gdbNewSignnum()
112 cond = vim.eval("input('Breakpoint condition: ', '')")
114 #Create breakpoint and add sign
115 b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : cond}
116 vim.command("sign place %(signnum)d line=%(lineno)d name=CondBreakPoint file=%(file)s" % b)
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>