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