From: Stefan Huber Date: Tue, 10 Jun 2008 14:52:14 +0000 (+0200) Subject: some code beautifying: __waitForPrompt X-Git-Tag: v0.99.0~14 X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=d7a00b7d9d8b49655f714abc53361bed08e0355d;p=pygdb.git some code beautifying: __waitForPrompt --- diff --git a/GdbTerminal.py b/GdbTerminal.py index 7c28236..f468f89 100755 --- a/GdbTerminal.py +++ b/GdbTerminal.py @@ -30,7 +30,6 @@ class GdbTerminal (DbgTerminal.DbgTerminal): self.waitForActivation(his) def setRun(self): - his = self.getHistoryLen() argv = string.join(string.split(self.clientCmd)[1:]) self.feed_child("run " + argv + "\n") @@ -83,15 +82,14 @@ class GdbTerminal (DbgTerminal.DbgTerminal): def delBreakpoint(self, breakpoint): + his = self.getHistoryLen() self.feed_child("del breakpoint %s\n" % (breakpoint,)) + self.waitForActivation(his) def getBreakpoints(self): starthis = self.getHistoryLen() self.feed_child("info breakpoints\n") - - rx = re.compile("^\(gdb\) ") - endhis, response = self.waitForRx(rx, starthis) - + endhis, response = self.__waitForPrompt(starthis) rxbp = re.compile("^\d+\s+breakpoint") rxpos = re.compile("^.* at \S+:\d+$") @@ -138,10 +136,7 @@ class GdbTerminal (DbgTerminal.DbgTerminal): his = self.getHistoryLen() self.feed_child("print " + expr + "\n") - - rx = re.compile("^\(gdb\)") - his, response = self.waitForRx(rx, his) - + his, response = self.__waitForPrompt(his) answer = self.history[his-1] if len(string.split(answer, "=")) == 1: @@ -154,8 +149,7 @@ class GdbTerminal (DbgTerminal.DbgTerminal): def waitForActivation(self, starthis): self.setActive(False) - rx = re.compile("^\(gdb\)") - endhis, response = self.waitForRx(rx,starthis) + endhis, response = self.__waitForPrompt(starthis) self.setActive(True) for his in reversed(range(starthis+1,endhis)): @@ -166,6 +160,12 @@ class GdbTerminal (DbgTerminal.DbgTerminal): return None + def __waitForPrompt(self, his): + rx = re.compile("^\(gdb\) ") + return self.waitForRx(rx,his) + + + if __name__ == "__main__":