21 def load(self
, filename
):
25 for line
in file(filename
).readlines():
29 cmd
= string
.split(line
)[0]
30 tail
= string
.join(string
.split(line
)[1:])
40 print "Unkown command", cmd
46 def store(self
, filename
):
48 f
= file(filename
, "w")
50 for b
in self
.breakpoints
:
51 self
.__writeBreak
(f
, b
)
53 for w
in self
.watches
:
54 self
.__writeWatch
(f
, w
)
61 def parseBreak(self
, tail
):
64 rx
= re
.compile("^[\w\._\-]+:\d+(\s+if\s+\S+.*)?$")
66 if not rx
.search(tail
):
67 print "Wrong breakpoint format:", tail
70 preif
= string
.split(tail
, "if")[0].strip()
71 postif
= string
.join( string
.split(tail
, "if")[1:], "if").strip()
73 [file,lineno
] = string
.split(preif
, ":")
80 self
.addBreak(file, lineno
, cond
)
82 def parseInt(self
, tail
):
84 rx
= re
.compile("^[\w_\-]+\s+\d+$")
86 if not rx
.search(tail
):
87 print "Wrong size format:", tail
90 [name
,val
] = string
.split(tail
)
92 self
.addInt(name
, val
)
94 def parseWatch(self
, tail
):
98 def __writeBreak(self
, f
, b
):
100 f
.write("break %(file)s:%(lineno)d if %(cond)s\n" % b
)
102 f
.write("break %(file)s:%(lineno)d\n" % b
)
104 def __writeInt(self
, f
, s
):
105 f
.write("int %(name)s %(val)d\n" % s
)
107 def __writeWatch(self
, f
, w
):
108 f
.write("watch %(expr)s\n" % w
)
111 def addBreak(self
, file, lineno
, cond
=None):
112 self
.breakpoints
+= [ {"file" : file, "lineno" : lineno
, "cond" : cond
} ]
114 def addInt(self
, name
, val
):
115 self
.ints
+= [{"name": name
, "val": val
}]
117 def addWatch(self
, expr
):
118 self
.watches
+= [ {"expr" : expr
.strip() } ]
121 def findInt(self
, name
):
123 if i
["name"] == name
:
129 return "breakpoints=" + str(self
.breakpoints
) + \
130 ", watches=" + str(self
.watches
) + \
131 ", ints=" + str(self
.ints
)