X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=Configuration.py;h=a8b4abfa8b768b5276bb932c18923285348339ae;hp=7dcd2908aca58e6f9013a752c3e8af982ce85908;hb=b029ee3dd1a5a785737e73ac6fc024a58d855104;hpb=f2698c930f26434a100e0b4c1e4f39291b55b4f9 diff --git a/Configuration.py b/Configuration.py index 7dcd290..a8b4abf 100755 --- a/Configuration.py +++ b/Configuration.py @@ -15,6 +15,7 @@ class Configuration: def __init__(self): self.breakpoints = [] self.watches = [] + self.ints = [] def load(self, filename): @@ -32,6 +33,8 @@ class Configuration: self.parseBreak(tail) elif cmd == "watch": self.parseWatch(tail) + elif cmd == "int": + self.parseInt(tail) else: cnt -= 1 print "Unkown command", cmd @@ -39,6 +42,7 @@ class Configuration: except IOError: return None + def store(self, filename): f = file(filename, "w") @@ -49,6 +53,10 @@ class Configuration: for w in self.watches: self.__writeWatch(f, w) + for s in self.ints: + self.__writeInt(f, s) + + def parseBreak(self, tail): @@ -71,6 +79,17 @@ class Configuration: self.addBreak(file, lineno, cond) + def parseInt(self, tail): + tail.strip() + rx = re.compile("^[\w_\-]+\s+\d+$") + + if not rx.search(tail): + print "Wrong size format:", tail + return + + [name,val] = string.split(tail) + val = int(val) + self.addInt(name, val) def parseWatch(self, tail): self.addWatch(tail) @@ -82,6 +101,9 @@ class Configuration: else: f.write("break %(file)s:%(lineno)d\n" % b) + def __writeInt(self, f, s): + f.write("int %(name)s %(val)d\n" % s) + def __writeWatch(self, f, w): f.write("watch %(expr)s\n" % w) @@ -89,11 +111,24 @@ class Configuration: def addBreak(self, file, lineno, cond=None): self.breakpoints += [ {"file" : file, "lineno" : lineno, "cond" : cond} ] + def addInt(self, name, val): + self.ints += [{"name": name, "val": val}] + def addWatch(self, expr): self.watches += [ {"expr" : expr.strip() } ] + + def findInt(self, name): + for i in self.ints: + if i["name"] == name: + return i["val"] + return None + + def __str__(self): - return "breakpoints=" + str(self.breakpoints) + ", watches=" + str(self.watches) + return "breakpoints=" + str(self.breakpoints) + \ + ", watches=" + str(self.watches) + \ + ", ints=" + str(self.ints)