Add LICENSE
[pygdb.git] / pygdb.py
1 #!/usr/bin/python
2 #shuber, 2008-06-08
3
4 __author__ = "shuber"
5
6 import gtk
7 import string
8 import sys
9
10 import Configuration
11 import GdbTerminal
12 import MainControlWindow
13 import StatusWindow
14
15
16
17 def getArgs():
18 args = {}
19
20 try:
21
22 i=1
23 while i < len(sys.argv):
24
25 if sys.argv[i] == "--help":
26 args["--help"] = True
27
28 elif sys.argv[i] == "--vim-servername":
29 i += 1
30 args["--vim-servername"] = sys.argv[i]
31
32 else:
33 args["cmd"] = string.join(sys.argv[i:])
34 return args
35
36 i += 1
37
38 except Exception:
39 return False
40
41 return args
42
43
44 def printHelp(f):
45
46 f.write("""Call pygdb with a specific command to be debugged.
47
48 Usage:
49 %s --help
50 %s [--vim-servername NAME] <command>
51
52 where <command> is the command to call the client that should
53 be debugged.
54
55 --help
56 Print help text.
57
58 --vim-servername NAME
59 The servername of the vim to communicate with
60 """ % (sys.argv[0], sys.argv[0]) )
61
62
63
64
65 if __name__ == "__main__":
66
67
68 #Get the arguments
69 args = getArgs()
70
71 if args == None:
72 printHelp(sys.stderr)
73 sys.exit(-1)
74
75 if "--help" in args.keys():
76 printHelp(sys.stdout)
77 sys.exit(0)
78
79 if not "cmd" in args.keys():
80 sys.stderr.write("Please give executeable to debug.")
81 sys.exit(-2)
82
83 if "--vim-servername" in args.keys():
84 vimservername = args["--vim-servername"]
85 else:
86 vimservername = "pygdb"
87
88
89
90 #Create Terminal
91 dbgterm = GdbTerminal.GdbTerminal(args["cmd"])
92
93 #Create windows
94 mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm)
95 statusWnd = StatusWindow.StatusWindow(dbgterm, vimservername)
96 dbgterm.initialize()
97
98 #Load configuration
99 conf = Configuration.Configuration()
100 conf.load(".pygdb.conf")
101 statusWnd.applyConfiguration(conf)
102
103 gtk.main()
104
105 #Store config
106 conf = Configuration.Configuration()
107 statusWnd.fillConfiguration(conf)
108 conf.delCurrpos()
109 conf.store(".pygdb.conf")
110
111 statusWnd.updateVim()
112
113
114