X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=pygdb.py;h=00d4d6430d31bd8649a33299794973b8b7e23ad1;hp=66fe63452f8f355adab3298b07b26b4c0455ea83;hb=HEAD;hpb=1094f7f4581a9c0074294004bbd8c934593a54d5 diff --git a/pygdb.py b/pygdb.py index 66fe634..00d4d64 100755 --- a/pygdb.py +++ b/pygdb.py @@ -7,33 +7,108 @@ import gtk import string import sys +import Configuration import GdbTerminal import MainControlWindow import StatusWindow -def launchDebugger(clientCmd): - #Create Terminal - dbgterm = GdbTerminal.GdbTerminal(clientCmd) - #Create windows - mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm) - statusWnd = StatusWindow.StatusWindow(mainCtrlWnd, dbgterm) - dbgterm.initialize() +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]) ) - gtk.main() if __name__ == "__main__": - #Check if enough arguments are given - if len(sys.argv) <= 1: - print "Please give executeable to debug." + + #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(args["cmd"]) + + #Create windows + mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm) + statusWnd = StatusWindow.StatusWindow(dbgterm, vimservername) + dbgterm.initialize() + + #Load configuration + conf = Configuration.Configuration() + conf.load(".pygdb.conf") + statusWnd.applyConfiguration(conf) + + gtk.main() + + #Store config + conf = Configuration.Configuration() + statusWnd.fillConfiguration(conf) + conf.delCurrpos() + conf.store(".pygdb.conf") + + statusWnd.updateVim() - #Create the terminals - clientCmd = string.join(sys.argv[1:]) - launchDebugger(clientCmd)