From 127bb50e7d884d3a413ab4b3b429e89b5dfebf74 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Mon, 23 Jun 2008 14:18:30 +0100 Subject: [PATCH] pygdb takes vim-servername as parameter. vim communicates its servername to pygdb --- DbgTerminal.py | 4 -- StatusWindow.py | 10 ++++- featurerequest.txt | 2 - pygdb.py | 92 ++++++++++++++++++++++++++++++++++++++-------- pygdb.vim | 5 ++- 5 files changed, 87 insertions(+), 26 deletions(-) diff --git a/DbgTerminal.py b/DbgTerminal.py index ab365de..a899a63 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -244,10 +244,6 @@ def quitHandler(*w): pass -def updateVim(): - os.system('gvim --servername pygdb --remote-send " :GDBLoadConfig"') - - def relToAbsPath(absfile, relfile): """When an absfile is given and a relfile is given by relative paths relative to absfile, determine the abs diff --git a/StatusWindow.py b/StatusWindow.py index 99382ff..f03c11c 100644 --- a/StatusWindow.py +++ b/StatusWindow.py @@ -20,9 +20,10 @@ import WatchesFrame class StatusWindow (gtk.Window): - def __init__(self, debugger): + def __init__(self, debugger, vimservername): gtk.Window.__init__(self) + self.vimservername = vimservername self.debugger = debugger self.debugger.gotActiveCallback += [self.updateValues] @@ -101,7 +102,12 @@ class StatusWindow (gtk.Window): self.fillConfiguration(conf) conf.store(".pygdb.conf") - DbgTerminal.updateVim() + self.updateVim() + def updateVim(self): + + os.system('gvim --servername %s --remote-send " :GDBLoadConfig"' % \ + self.vimservername) + diff --git a/featurerequest.txt b/featurerequest.txt index 8a02147..cba74fe 100644 --- a/featurerequest.txt +++ b/featurerequest.txt @@ -4,8 +4,6 @@ Medium requestes: - Deactivate breakpoints Bigger requests: - - several vim sessions are not possible since servername - is always the same. --> parametrize servername by vim - bidirectional, immediate communication with vim: updating breakpoints when setting in vim. diff --git a/pygdb.py b/pygdb.py index bbdd04e..b562c75 100755 --- a/pygdb.py +++ b/pygdb.py @@ -15,14 +15,86 @@ import MainControlWindow import StatusWindow -def launchDebugger(clientCmd): + +def getArgs(): + args = {} + + try: + + i=1 + while i < len(sys.argv): + + if sys.argv[i] == "--help": + args["--help"] = True + + elif sys.argv[i] == "--vim-servername": + i += 1 + args["--vim-servername"] = sys.argv[i] + + else: + args["cmd"] = string.join(sys.argv[i:]) + return args + + i += 1 + + except Exception, e: + return False + + return args + + +def printHelp(f): + + f.write("""Call pygdb with a specific command to be debugged. + +Usage: + %s --help + %s [--vim-servername NAME] + +where is the command to call the client that should +be debugged. + + --help + Print help text. + + --vim-servername NAME + The servername of the vim to communicate with +""" % (sys.argv[0], sys.argv[0]) ) + + + + +if __name__ == "__main__": + + + #Get the arguments + args = getArgs() + + if args == None: + printHelp(sys.stderr) + sys.exit(-1) + + if "--help" in args.keys(): + printHelp(sys.stdout) + sys.exit(0) + + if not "cmd" in args.keys(): + sys.stderr.write("Please give executeable to debug.") + sys.exit(-2) + + if "--vim-servername" in args.keys(): + vimservername = args["--vim-servername"] + else: + vimservername = "pygdb" + + #Create Terminal - dbgterm = GdbTerminal.GdbTerminal(clientCmd) + dbgterm = GdbTerminal.GdbTerminal(args["cmd"]) #Create windows mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm) - statusWnd = StatusWindow.StatusWindow(dbgterm) + statusWnd = StatusWindow.StatusWindow(dbgterm, vimservername) dbgterm.initialize() #Load configuration @@ -38,19 +110,7 @@ def launchDebugger(clientCmd): conf.delCurrpos() conf.store(".pygdb.conf") - DbgTerminal.updateVim() - - - -if __name__ == "__main__": - - #Check if enough arguments are given - if len(sys.argv) <= 1: - print "Please give executeable to debug." - sys.exit(-1) + statusWnd.updateVim() - #Create the terminals - clientCmd = string.join(sys.argv[1:]) - launchDebugger(clientCmd) diff --git a/pygdb.vim b/pygdb.vim index d50d240..7a8b89f 100644 --- a/pygdb.vim +++ b/pygdb.vim @@ -28,7 +28,7 @@ clientcmd = "" execsign = None def gdbLaunch(): - global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread + global gdbBps, clientcmd clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip() @@ -44,7 +44,7 @@ def gdbLaunch(): conf.addBreak(bp["file"], bp["lineno"], bp["cond"]) conf.store(".pygdb.conf") - 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): @@ -238,6 +238,7 @@ def gdbLoadConfig(): setExecutionLine(file, conf.currlineno) else: delExecutionLine() + >> highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=Black guibg=LightGreen guifg=Black -- 2.39.5