X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=pygdb.py;h=00d4d6430d31bd8649a33299794973b8b7e23ad1;hp=422f83a812b10d15476f98d017b5f64fc1ee08ea;hb=HEAD;hpb=0296b6d5afe20a15764842873917bf1d6aa34b77 diff --git a/pygdb.py b/pygdb.py index 422f83a..00d4d64 100755 --- a/pygdb.py +++ b/pygdb.py @@ -4,7 +4,6 @@ __author__ = "shuber" import gtk -import os import string import sys @@ -14,14 +13,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: + 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 @@ -34,19 +105,10 @@ def launchDebugger(clientCmd): #Store config conf = Configuration.Configuration() statusWnd.fillConfiguration(conf) + conf.delCurrpos() conf.store(".pygdb.conf") + + statusWnd.updateVim() -if __name__ == "__main__": - - #Check if enough arguments are given - if len(sys.argv) <= 1: - print "Please give executeable to debug." - sys.exit(-1) - - #Create the terminals - clientCmd = string.join(sys.argv[1:]) - launchDebugger(clientCmd) - -