pygdb takes vim-servername as parameter. vim communicates its servername to pygdb
authorStefan Huber <shuber2@gmail.com>
Mon, 23 Jun 2008 13:18:30 +0000 (14:18 +0100)
committerStefan Huber <shuber2@gmail.com>
Mon, 23 Jun 2008 13:18:30 +0000 (14:18 +0100)
DbgTerminal.py
StatusWindow.py
featurerequest.txt
pygdb.py
pygdb.vim

index ab365deb4245bde09116810e2ecdea9c84cbe779..a899a6358bdbdc3a4f4c6896bb6d16d69f8c6dba 100644 (file)
@@ -244,10 +244,6 @@ def quitHandler(*w):
                pass
 
 
-def updateVim():
-       os.system('gvim --servername pygdb --remote-send "<ESC> :GDBLoadConfig<CR>"')
-
-
 def relToAbsPath(absfile, relfile):
        """When an absfile is given and a relfile is given by
        relative paths relative to absfile, determine the abs
index 99382ff1d684c9caaa80aa99992398619e3138f4..f03c11c27d579173db6641aa42d5394b842d9e52 100644 (file)
@@ -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 "<ESC> :GDBLoadConfig<CR>"' % \
+                       self.vimservername)
+
 
index 8a021479a33b45cea0394097c0db249b2c282812..cba74fe7e2a28f7de4468c5cca56b0b82b59401b 100644 (file)
@@ -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.
          
index bbdd04e7aa389491e79743f680e0bc6b61b37b70..b562c75735efea26de4e3b5b6bd428831723c2d9 100755 (executable)
--- 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] <command>
+
+where <command> 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)
 
 
index d50d2400cbc1a6c1fb09bdb624cf764919ae398c..7a8b89f45901be31ed691ac53b268cb84ef0022d 100644 (file)
--- 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