X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=pygdb.vim;h=79a557e074dafc0824832121de074825bd03e619;hb=5b266c92e0dd3c0d33ed893ffbc9ec786adf6226;hp=e505b0aca7c938994a9725403cbce21efa63526f;hpb=b7f4eaf787ec9c54f36cce00bb294a8be2a862c3;p=pygdb.git diff --git a/pygdb.vim b/pygdb.vim index e505b0a..79a557e 100644 --- a/pygdb.vim +++ b/pygdb.vim @@ -1,4 +1,11 @@ -"shuber, 2008-06-08 +"pygdb.vim - pygtk interface to gdb in connection with (g)vim +" Maintainer: Stefan Huber + + +if !has('python') + echo "Error: Required vim compiled with +python" + finish +endif if ! exists("g:pygdb") @@ -16,6 +23,7 @@ import threading import vim import Configuration +import DbgTerminal @@ -27,22 +35,25 @@ clientcmd = "" execsign = None def gdbLaunch(): - global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread + global gdbBps, clientcmd, pygdbdir + + clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd) + + #Pressed esq? + if clientcmd == None: + clientcmd = "" + return - clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip() + #Strip away white space + clientcmd = clientcmd.strip() if clientcmd.strip()=="": print "No command given!" return - #Add the breakpoints to the configuration - conf = Configuration.Configuration() - conf.load(".pygdb.conf") - for bp in gdbBps: - conf.addBreak(bp["file"], bp["lineno"], bp["cond"]) - conf.store(".pygdb.conf") + gdbWriteConfig() - vim.command("!python %s/pygdb.py %s &\n" % (pygdbdir, clientcmd)) + vim.command("!python %s/pygdb.py --vim-servername %s %s &\n" % (pygdbdir, vim.eval("v:servername"), clientcmd)) def gdbToggleBreakpoint(lineno=None, file=None): @@ -187,27 +198,7 @@ def gdbShowBreakpoints(): print "%(file)s:%(lineno)d" % bp -def getAbsPath(absfile, relfile): - """When an absfile is given and a relfile is given by - relative paths relative to absfile, determine the abs - path of relfile""" - - #Get directories except for "." parts - relsplit = filter(lambda x: x!=".", string.split(relfile, os.sep)) - #Get the directories of absfile withouth the trailing filename - abssplit = string.split(absfile, os.sep)[:-1] - - #Determine number of ".." and remove them - up=0 - while relsplit[0] == "..": - up += 1 - del relsplit[0] - del abssplit[-1] - - return string.join(abssplit + relsplit, os.sep) - -#Change to absolute path def toAbsPath(path): global clientcmd, cmdset @@ -216,13 +207,18 @@ def toAbsPath(path): #We need the client command to expand the paths... while clientcmd == "" or not cmdset: - clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip() + clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd) + + if clientcmd == None: + clientcmd = "" + clientcmd = clientcmd.strip() + cmdset = True #Get the dirs where executeable is in relcmd = string.split(clientcmd)[0] - abscmd = getAbsPath(getCurrentFile(), relcmd) - path = getAbsPath(abscmd, path) + abscmd = DbgTerminal.relToAbsPath(getCurrentFile(), relcmd) + path = DbgTerminal.relToAbsPath(abscmd, path) assert(path[0] == "/") @@ -233,8 +229,6 @@ def gdbLoadConfig(): global clientcmd, gdbBps, cmdset - - #Load configuration conf = Configuration.Configuration() conf.load(".pygdb.conf") @@ -247,6 +241,10 @@ def gdbLoadConfig(): for bp in conf.breakpoints: bp["file"] = toAbsPath( bp["file"] ) addBreakpoint(bp["file"], bp["lineno"], bp["cond"]) + + #Set the command from config + if conf.getCommand() != None: + clientcmd = conf.getCommand() #Set current execution line if conf.isCurrposSet(): @@ -254,6 +252,19 @@ def gdbLoadConfig(): setExecutionLine(file, conf.currlineno) else: delExecutionLine() + + +def gdbWriteConfig(): + + #Add the breakpoints to the configuration + conf = Configuration.Configuration() + conf.load(".pygdb.conf") + conf.breakpoints = [] + for bp in gdbBps: + conf.addBreak(bp["file"], bp["lineno"], bp["cond"]) + conf.store(".pygdb.conf") + + >> highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=Black guibg=LightGreen guifg=Black