21 def load(self
, filename
):
25 f
= file(filename
, "r")
26 for line
in f
.readlines():
30 cmd
= string
.split(line
)[0]
31 tail
= string
.join(string
.split(line
)[1:])
41 print "Unkown command", cmd
49 def store(self
, filename
):
51 f
= file(filename
, "w")
53 for b
in self
.breakpoints
:
54 self
.__writeBreak
(f
, b
)
56 for w
in self
.watches
:
57 self
.__writeWatch
(f
, w
)
70 def parseBreak(self
, tail
):
73 rx
= re
.compile("^[\w/\._\-]+:\d+(\s+if\s+\S+.*)?$")
75 if not rx
.search(tail
):
76 print "Wrong breakpoint format:", tail
79 preif
= string
.split(tail
, "if")[0].strip()
80 postif
= string
.join( string
.split(tail
, "if")[1:], "if").strip()
82 [file,lineno
] = string
.split(preif
, ":")
89 self
.addBreak(file, lineno
, cond
)
91 def parseInt(self
, tail
):
93 rx
= re
.compile("^[\w_\-]+\s+\d+$")
95 if not rx
.search(tail
):
96 print "Wrong size format:", tail
99 [name
,val
] = string
.split(tail
)
101 self
.addInt(name
, val
)
103 def parseWatch(self
, tail
):
107 def __writeBreak(self
, f
, b
):
108 if b
["cond"] != None:
109 f
.write("break %(file)s:%(lineno)d if %(cond)s\n" % b
)
111 f
.write("break %(file)s:%(lineno)d\n" % b
)
113 def __writeInt(self
, f
, s
):
114 f
.write("int %(name)s %(val)d\n" % s
)
116 def __writeWatch(self
, f
, w
):
117 f
.write("watch %(expr)s\n" % w
)
120 def addBreak(self
, file, lineno
, cond
=None):
121 bp
= {"file" : file, "lineno" : lineno
, "cond" : cond
}
122 if not bp
in self
.breakpoints
:
123 self
.breakpoints
+= [bp
]
125 def addInt(self
, name
, val
):
126 i
= {"name": name
, "val": val
}
127 if not i
in self
.ints
:
130 def addWatch(self
, expr
):
131 w
= {"expr" : expr
.strip() }
132 if not w
in self
.watches
:
136 def findInt(self
, name
):
138 if i
["name"] == name
:
144 return "breakpoints=" + str(self
.breakpoints
) + \
145 ", watches=" + str(self
.watches
) + \
146 ", ints=" + str(self
.ints
)