X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=pygdb.vim;h=e505b0aca7c938994a9725403cbce21efa63526f;hp=fc03b84404d48cf050f4f1116db99c5aeec2c6f2;hb=b7f4eaf787ec9c54f36cce00bb294a8be2a862c3;hpb=e8f5eba24b3fd5cdd839bcfc170a2e3aa16dd05d diff --git a/pygdb.vim b/pygdb.vim index fc03b84..e505b0a 100644 --- a/pygdb.vim +++ b/pygdb.vim @@ -24,6 +24,7 @@ import Configuration gdbBps = [] signnum = 0 clientcmd = "" +execsign = None def gdbLaunch(): global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread @@ -62,8 +63,42 @@ def gdbToggleBreakpoint(lineno=None, file=None): addBreakpoint(file, lineno) +def setExecutionLine(file, lineno): + global execsign + + + #Open that file! + if file != getCurrentFile(): + try: + os.stat(file) + vim.command(":e %s" % file) + except OSError: + print "Warning: file '%s' does not exist! (Wrong client command?)" % file + return + + #Jump to line + vim.command(":%d" % lineno) + + #Remove old execsign + if execsign != None: + delExecutionLine() + + #Set the sign + execsign = gdbNewSignnum() + vim.command("sign place %d line=%s name=ExecutionLine file=%s"%(execsign, lineno, file)) + + +def delExecutionLine(): + global execsign + + #Remove old execsign + if execsign != None: + vim.command("sign unplace %d" % execsign) + execsign = None + + def addBreakpoint(file, lineno, cond=None): - global gdbBps + global gdbBps, cmdset #If file is not open, open it if not file in [b.name for b in vim.buffers]: @@ -72,6 +107,7 @@ def addBreakpoint(file, lineno, cond=None): vim.command(":e %s" % file) except OSError: print "Warning: file '%s' does not exist! (Wrong client command?)" % file + cmdset = False return @@ -171,9 +207,32 @@ def getAbsPath(absfile, relfile): return string.join(abssplit + relsplit, os.sep) +#Change to absolute path +def toAbsPath(path): + global clientcmd, cmdset + + #Not a absolute path --> make one + if path[0] != os.sep: + + #We need the client command to expand the paths... + while clientcmd == "" or not cmdset: + clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip() + cmdset = True + + #Get the dirs where executeable is in + relcmd = string.split(clientcmd)[0] + abscmd = getAbsPath(getCurrentFile(), relcmd) + path = getAbsPath(abscmd, path) + + assert(path[0] == "/") + + return path + def gdbLoadConfig(): - global clientcmd, gdbBps + global clientcmd, gdbBps, cmdset + + #Load configuration @@ -185,38 +244,26 @@ def gdbLoadConfig(): removeBreakpoint(0) #Add breakpoints from configuration - cmdset = False for bp in conf.breakpoints: - - file = bp["file"] - - #Not a absolute path --> make one - if file[0] != os.sep: - - #We need the client command to expand the paths... - while clientcmd == "" or not cmdset: - clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip() - cmdset = True - - #Get the dirs where executeable is in - relcmd = string.split(clientcmd)[0] - abscmd = getAbsPath(getCurrentFile(), relcmd) - bp["file"] = file = getAbsPath(abscmd, file) - - assert(file[0] == "/") - + bp["file"] = toAbsPath( bp["file"] ) addBreakpoint(bp["file"], bp["lineno"], bp["cond"]) - + + #Set current execution line + if conf.isCurrposSet(): + file = toAbsPath(conf.currfile) + setExecutionLine(file, conf.currlineno) + else: + delExecutionLine() >> +highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=Black guibg=LightGreen guifg=Black +highlight BreakPoint term=inverse ctermbg=DarkRed ctermfg=Black guibg=LightRed guifg=Black -highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black - +sign define ExecutionLine text==> texthl=ExecutionLine linehl=ExecutionLine sign define BreakPoint text=! texthl=BreakPoint linehl=BreakPoint sign define CondBreakPoint text=? texthl=BreakPoint linehl=BreakPoint - command! GDBLaunch :python gdbLaunch() command! GDBToggleBreakpoint :python gdbToggleBreakpoint() command! GDBBreakpointCond :python gdbBreakpointCond()