forked from vim-scripts/pygdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pygdb.py
114 lines (72 loc) · 1.81 KB
/
pygdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/python
#shuber, 2008-06-08
__author__ = "shuber"
import gtk
import string
import sys
import Configuration
import GdbTerminal
import MainControlWindow
import StatusWindow
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] <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(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()