+
+ def listCodeSnippet(self):
+ return self.__getAnswerFromCmd("list\n")
+
+ def getBacktrace(self):
+ return self.__getAnswerFromCmd("bt\n")
+
+ def waitForPrompt(self, his):
+ rx = "^\(gdb\)"
+ return self.waitForRx(rx,his)
+
+ def __getAnswerFromCmd(self, cmd):
+ starthis = self.getHistoryLen()
+ self.feed_child(cmd)
+ endhis, response = self.waitForPrompt(starthis)
+
+ return self.history[starthis:endhis]
+
+
+ def testForActivity(self, his):
+ """Test whether debugger got active again"""
+
+ line = self.history[his]
+
+ if string.find(line, "\x1a\x1a") == 0:
+ tuples = string.split(line[2:], ":")
+ tuples[1] = int(tuples[1])
+ return "break", [tuples[0], int(tuples[1])]
+
+ if string.find(line, "Program exited") == 0:
+ code = string.split(line)[-1]
+
+ codeno = 0
+
+ #Parse the octal number
+ if code[0] == "O":
+ code = code[1:-1]
+ for c in code:
+ codeno = codeno*8 + int(c)
+
+ return "exited", codeno
+
+ return None
+
+
+ def testForInactivity(self, his):
+ """Test whether debugger got inactive"""
+ line = self.history[his]
+
+ if string.find(line, "Starting program:") == 0:
+ prog = string.join( string.split(line)[1:])
+ return "started", prog
+
+ if string.find(line, "Continuing.") == 0:
+ return "continued", None
+
+ if string.find(line, "\x1a\x1a") == 0:
+ rxcont = re.compile("^\(gdb\)\s+(cont|step|next|stepi|nexti|advance)")
+
+ if rxcont.search(self.history[his-1]):
+ return "stepped", None
+ if rxcont.search(self.history[his-2]):
+ return "stepped", None
+
+ return None
+
+
+
+
+
+